【发布时间】:2014-03-01 22:10:36
【问题描述】:
In my android application I have a spinner containing different calculators, and when a calculator is selected it shows up in a scrollview below.当屏幕设置为水平时,布局会发生变化,滚动视图在右侧,而微调器在左侧,并且都以相同的方式工作。
但是,当屏幕处于水平位置时,列表视图会更好看,但我似乎找不到在 java 代码中进行切换的方法。
有人可以帮忙吗?
这是初始化方法的代码,我想知道是否有一种方法可以插入一个 if 语句,如果屏幕是垂直的,微调器将被初始化,如果屏幕是水平的,则列表视图将被初始化.
private void initialize() {
valg_vertical = (Spinner) findViewById(R.id.sKalk);
// Adds the custom look for the spinner
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.custom_spinner, getResources().getStringArray(
R.array.calculator));
adapter.setDropDownViewResource(SpinnerItemLayout);
valg_vertical.setAdapter(adapter);
// Adds the custom look for the spinner
lLayout = (LinearLayout) findViewById(R.id.lInSVKalk);
valg_vertical.setOnItemSelectedListener(this);
}
【问题讨论】:
标签: java android listview orientation spinner