Note that there are some explanatory texts on larger screens.

plurals
  1. POAlways open tab first then open other tabs
    primarykey
    data
    text
    <p>I have tab activity with third tab</p> <p>TabMainActivity</p> <pre><code>public class TabMainActivity extends TabActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TabHost tabHost = getTabHost(); Intent it=getIntent(); int num_tab=it.getIntExtra("num_tab", 0); // Tab1 TabSpec photospec = tabHost.newTabSpec("Tab1"); // setting Title and Icon for the Tab photospec.setIndicator("Tab1", getResources().getDrawable(R.drawable.icon_photos_tab)); Intent photosIntent = new Intent(this, PhotosActivity.class); photospec.setContent(photosIntent); // Tab2 TabSpec songspec = tabHost.newTabSpec("Tab2"); songspec.setIndicator("Songs", getResources().getDrawable(R.drawable.icon_songs_tab)); Intent songsIntent = new Intent(this, SongsActivity.class); songspec.setContent(songsIntent); // Tab3 TabSpec videospec = tabHost.newTabSpec("Tab3"); videospec.setIndicator("Videos", getResources().getDrawable(R.drawable.icon_videos_tab)); Intent videosIntent = new Intent(this, VideosActivity.class); videospec.setContent(videosIntent); // Adding all TabSpec to TabHost tabHost.addTab(photospec); // Adding photos tab tabHost.addTab(songspec); // Adding songs tab tabHost.addTab(videospec); // Adding videos tab tabHost.setCurrentTab(num_tab); } </code></pre> <p>}</p> <p><strong>Tab1: Activity1.java</strong></p> <pre><code>public class Activity1 extends Activity { @Override public void onCreate(Bundle circle) { super.onCreate(circle); setContentView(R.layout.layout1); Toast.makeText(getBaseContext(), "This is tab1",Toast.LENGTH_LONG).show(); } </code></pre> <p>}</p> <p><strong>Tab2: Activity2.java</strong></p> <pre><code>public class Activity2 extends Activity { @Override public void onCreate(Bundle circle) { super.onCreate(circle); setContentView(R.layout.layout1); } </code></pre> <p>}</p> <p><strong>Tab3: Activity3.java</strong></p> <pre><code>public class Activity3 extends Activity { @Override public void onCreate(Bundle circle) { super.onCreate(circle); setContentView(R.layout.layout1); Button button3=(Button)findViewbyId(R.id.button3); button3.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub Activity3.this.finish(); Intent it=new Intent(Activity3.this,TabMainActivity.class); it.putExtra("num_tab",2); startActivity(it); } }); } </code></pre> <p>}</p> <p>Now,if in tab3 i click button3..It always operations codes in tab1(display toast as code)..then open again tab3.I only want to open again tab3 but don't operation codes in tab1.. How must i do?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload