我正在尝试使用ViewFlow类制作一个不错的水平视图组。
我想把它和按钮结合起来。例如,当我单击按钮 2 时,我会转到视图组的视图 2。那可能吗?我目前得到了这个:
public class HousingActivity extends BaseActivity implements OnClickListener {
ViewFlow viewFlow;
ListView listView;
HousingViewflowAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.housing_activity);
init();
}
private void init() {
viewFlow = (ViewFlow) findViewById(R.id.viewflow);
setOnClickListner(this, this, new int[] { R.id.housing_button1,
R.id.housing_button2, R.id.housing_button3,
R.id.housing_button4 });
adapter = new HousingViewflowAdapter(this);
viewFlow.setAdapter(adapter);
viewFlow.setOnViewSwitchListener(new ViewSwitchListener() {
@Override
public void onSwitched(View view, int position) {
}
});
listView = (ListView) findViewById(R.id.housing_view1_listview);
ArrayList<Community> communityList = new ArrayList<Community>();
// Some dummy data
for (int i = 0; i < 10; i++) {
communityList.add(new Community("Place " + new Random().nextInt(),
new Random().nextInt(), 000000000, ""));
}
listView.setAdapter(new MainListViewAdapter(this, 0, communityList));
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// viewFlow.onConfigurationChanged(newConfig);
}
@Override
public void onClick(View v) {
super.onClick(v);
switch (v.getId()) {
case R.id.housing_button1:
break;
case R.id.housing_button2:
break;
case R.id.housing_button3:
break;
case R.id.housing_button4:
break;
}
}
}
提前致谢。