fragment显示了一个listview,怎么使其点击有效
1个回答
展开全部
主activity是这样
[mw_shl_code=java,true]public class MainTabHostActivity extends FragmentActivity{
private FragmentTabHost mTabHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost);
mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator("软件"),SoftwareFragment.class,null);
mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator("日志"),SoftwareFragment.class,null);
mTabHost.addTab(mTabHost.newTabSpec("tab3").setIndicator("权限"),SoftwareFragment.class,null);
mTabHost.addTab(mTabHost.newTabSpec("tab3").setIndicator("设置"),SoftwareFragment.class,null);
}
}[/mw_shl_code]
在onCreateView里面少了句:softwareListView.setOnItemClickListener(this);
[mw_shl_code=java,true]public class MainTabHostActivity extends FragmentActivity{
private FragmentTabHost mTabHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost);
mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator("软件"),SoftwareFragment.class,null);
mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator("日志"),SoftwareFragment.class,null);
mTabHost.addTab(mTabHost.newTabSpec("tab3").setIndicator("权限"),SoftwareFragment.class,null);
mTabHost.addTab(mTabHost.newTabSpec("tab3").setIndicator("设置"),SoftwareFragment.class,null);
}
}[/mw_shl_code]
在onCreateView里面少了句:softwareListView.setOnItemClickListener(this);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询