我正在使用 tabview。我的标签小部件视图中有 3 个标签。下面是我的 MainActivity.java
public class MainActivity extends Activity {
TabHost host;
Intent intent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Resources res = getResources();
host = (TabHost) findViewById (R.id.tabhost);
host.setup();
TabSpec tspecMovies = host.newTabSpec("tag1");
// tspecMovies.setContent(R.id.tab1);
tspecMovies.setIndicator("Movies", res.getDrawable(R.drawable.movie_icon));
host.addTab(tspecMovies);
TabSpec tspecTv = host.newTabSpec("tag2");
// tspecTv.setContent(R.id.tab2);
tspecTv.setIndicator("TV", res.getDrawable(R.drawable.tv_icon));
host.addTab(tspecTv);
TabSpec tspecEvents = host.newTabSpec("tag3");
// tspecEvents.setContent(R.id.tab3);
tspecEvents.setIndicator("Events", res.getDrawable(R.drawable.event_icon));
host.addTab(tspecEvents);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
对于每个包含选项卡内容的选项卡,我有 3 个不同的活动。我想知道单击选项卡时如何在 onClick 事件上调用这些活动。