1. Download our Official Android App: Forums for Android!

Tabs in every activity in android

Discussion in 'Android Apps & Games' started by jomia, Nov 4, 2010.

  1. jomia

    jomia Lurker
    Thread Starter
    Nov 4, 2010

    Nov 4, 2010
    Hi, My first page contains 3 tabs. I want to retain all these 3 tabs through out my entire application. That means I want to see these 3 tabs in every view. For example : I have 3 views. First view is Main.class. It contains 3 tabs (Home tab, Favourite tab, settings tab). When I am clicking any one tab (Ex: Home Tab), it shows the contents of Home.class (a ListView) below these tabs. But when I am clicking the ListView view , it will go to another activity(SubListView.class), and I can't see the tabs in that activity. Only contents of that view will be displayed there. How can I show these header tabs in that view also?
    Main View: (in Main.class)
    final TabHost tabHost = getTabHost(); Intent intent; LayoutInflater.from(this).inflate(R.layout.main, tabHost.getTabContentView(),true); tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("Home",getResources().getDrawable(R.drawable.img_home)).setContent(new Intent(this, Home.class))); tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("Favourites",getResources().getDrawable(R.drawable.img_fav)).setContent(new Intent(this, Favourites.class))); tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("Settings",getResources().getDrawable(R.drawable.img_set)).setContent(new Intent(this, Settings.class))); tabHost.setCurrentTab(0); Home View: (in Home.class)
    public ArrayAdapter<String> adapter; final ArrayList<String> results = new ArrayList<String>(); ListView listitems=(ListView)findViewById(R.id.list); adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,results); listitems.setAdapter(adapter); listitems.setOnItemClickListener(new AdapterView.OnItemClickListener() { //@Override public void onItemClick(AdapterView arg0, View view, int position, long id) { categoryNameFromList=results.get(position); Bundle category_bundle = new Bundle(); category_bundle.putString("selected_item",categoryNameFromList); Intent category_intent = new Intent(view.getContext(), SubListView.class); category_intent.putExtras(category_bundle); startActivityForResult(category_intent, 1); } }); SubList View (in SubListView.class)
    TextView txtmessage=new TextView(this); txtmessage.setTex("WELOCME TO SUB LIST VIEW!!"); setContentView(txtmessage); Please help me.. Thanking you in advance..


Share This Page