Tab and Intent Problems

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Tab and Intent Problems

Postby limteckchai » Tue Jun 29, 2010 5:14 am

Hi all, :x
i am trying to make an app, but i am facing some problems here.
My apps consist of a search banner which remains on the top of the screen, and below it is a tabwidget which allows the switch of the tabs. What i want is, to have the invoke an intent by clicking a button inside one of the tabs, and then it should appear the info i want.
The problem here is that the top banner suppose to be there goes missing after i call out another activity :oops:

:darrow: What i have :darrow: :oops:
_________________________
|Banner |
---------------------------------
|tab 1 | tab 2 | tab 3 | tab4|
---------------------------- -|
| (button) |
| |
---------------------------------
:darrow: After clicking :darrow: :oops:
_________________________
|my stuff here my stuff here|
|my stuff here my stuff here|
|my stuff here my stuff here|
|my stuff here my stuff here|
|my stuff here my stuff here|
|my stuff here my stuff here|
|_______________________|

:darrow: What i want after clicking is :darrow:
_________________________
|Banner |
---------------------------------
|tab 1 | tab 2 | tab 3 | tab4|
---------------------------- -|
|my stuff here my stuff here|
|my stuff here my stuff here|
|my stuff here my stuff here|
|_______________________|

This is how i made my tabs
Code: Select all
public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);

      Resources res = getResources();
      TabHost tabHost = getTabHost();
      TabHost.TabSpec spec;
      Intent intent;

      // Find Tab
      intent = new Intent().setClass(this, Find.class);
      spec = tabHost.newTabSpec("FIND").setIndicator("FIND",
            res.getDrawable(R.drawable.find)).setContent(intent);
      tabHost.addTab(spec);

      // Makan Tab
      intent = new Intent().setClass(this, makan.class);
      spec = tabHost.newTabSpec("MAKAN").setIndicator("MAKAN",
            res.getDrawable(R.drawable.makan)).setContent(intent);
      tabHost.addTab(spec);

And this is how ithe inside of one of my tabs
Code: Select all
protected void onListItemClick(ListView l, View v, int position, long id) {
      super.onListItemClick(l, v, position, id);
      
      Intent myIntent = new Intent().setClass(this, Home.class);
       startActivity(myIntent);


What happens when i run the code is that, the banner is no more there, and the new content takes over.

What i would like help with is some suggestions as to how to make sure the banner is still there after i call a new activity. I do not want to do it via hardcoding if it is possible.
I am looking for ways to correct this, and not looking for a free labour to help me do my work, thus i am not posting my code as i would rather do it myself with some hints. :roll:
In any case, thanks in advance and sorry for getting such a long post :oops:
limteckchai
Experienced Developer
Experienced Developer
 
Posts: 92
Joined: Mon Jun 28, 2010 3:33 am

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 4 guests