开发者

How to launch new Activity within TabHost

开发者 https://www.devze.com 2023-04-02 21:08 出处:网络
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 \

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.


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);

So if YourClass is a ListActivity the inside you can put a pop up dialog for example with another List with customer details and then you can add a close button. For your dialog you can setup a custom view a list view with an adapter or something else. For example in a method:

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(

}

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号