To start the Activity inside the Tab Bar with out affect the Tab Bar, To perform multiple action inside a single Tab
1.MainActivity.java
Add Tabs in normal way to the TabHost
here
are extends the ActivityGroup class
Tab1Activity.java
using ActivityManger i have start Tab11Activty inside the Tab1Activity that hole view incorporate inside the TabBar view, using this method we can perform multiple action inside the single TabBar
1.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // create the TabHost that will contain the Tabs TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost); TabHost.TabSpec tab1 = tabHost.newTabSpec("First Tab"); TabHost.TabSpec tab2 = tabHost.newTabSpec("Second Tab"); TabHost.TabSpec tab3 = tabHost.newTabSpec("Third tab"); // Set the Tab name and Activity // that will be opened when particular Tab will be selected tab1.setIndicator("Tab1"); tab1.setContent(new Intent(this,Tab1Activity.class)); tab2.setIndicator("Tab2"); tab2.setContent(new Intent(this,Tab2Activity.class)); tab3.setIndicator("Tab3"); tab3.setContent(new Intent(this, Tab3Activity.class)); /** Add the tabs to the TabHost to display. */ tabHost.addTab(tab1); tabHost.addTab(tab2); tabHost.addTab(tab3); }
Add Tabs in normal way to the TabHost
here
Tab1Activity.class
Tab2Activity.class
Tab3Activity.class
are extends the ActivityGroup class
Tab1Activity.java
public class Tab1Activity extends ActivityGroup {
protected static LocalActivityManager mLocalActivityManager;
Button launchButton;
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_a);
launchButton = (Button)findViewById(R.id.btn_a1);
launchButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
Intent activity3Intent = new Intent(v.getContext(), Tab11Activity.class);
StringBuffer urlString = new StringBuffer();
replaceContentView("activity3", activity3Intent);
}
});
}
public void replaceContentView(String id, Intent newIntent) {
View view = getLocalActivityManager().startActivity(id,newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
this.setContentView(view);
}
}
using ActivityManger i have start Tab11Activty inside the Tab1Activity that hole view incorporate inside the TabBar view, using this method we can perform multiple action inside the single TabBar
No comments:
Post a Comment