I'm using TabHost to display 3 tabs within my application (dashboard, orders and customers). Each of these is a seperate Activity containing a ListView and is working correctly. They all feature an 'endless scrolling' system like within Android Marketplace and retain their positions within the ListView when you switch between different tabs. When you click on an item within the ListView it currently loads up a brand new Activity full screen and leaves the TabHost. I'd like to load up these Activities within the TabHost (eg. Click on a specific customer within the customers list which then takes you to view the customers details whilst remaining within the customers tab. You can then return to the customers list without loosing your position/reloading the list). I've read about ActivityGroup and ViewFlipper but I'm struggling to suss out how to achieve the behaviour I desire.
问问题
1013 次
1 回答
0
mTabHost = getTabHost();
mTabHost.setOnTabChangedListener(this);
TabSpec spec;
String Tab_title3 = "NameofTab";
TextView txtTabInfo3 = new TextView(this);
setUpTextView(txtTabInfo3);
txtTabInfo3.setText(Tab_title3);
intent = new Intent();
intent.setClass(this, YourClass.class);
spec = mTabHost.newTabSpec(Tab_title3).setIndicator(txtTabInfo3)
.setContent(intent);
mTabHost.addTab(spec);
因此,如果 YourClass 是一个 ListActivity ,您可以在里面放置一个弹出对话框,例如另一个带有客户详细信息的列表,然后您可以添加一个关闭按钮。对于您的对话框,您可以使用适配器或其他东西设置自定义视图列表视图。例如在一个方法中:
buildMyDialog(){
final Dialog dialog = new Dialog(this);
lv2=new ListView(this);
lv2.setAdapter(mAdapter2);
//....
final Button cancelButton=new Button(this);
dialog.setContentView(lv2);
dialog.show(
}
于 2011-09-07T09:11:02.577 回答