Note that there are some explanatory texts on larger screens.

plurals
  1. POBack Button does not work with TabActivity and Group Activity
    text
    copied!<p>I have a problem with back button in the tabactivity and group activity.</p> <p>Now I have a 4 tab, in a tab I have one more activity. The back button doesn't work with group activity and tabactivity. How can I make this work?</p> <p>Here is my code:</p> <p><strong>for tabbar</strong></p> <pre><code> public class TabbarActivity extends TabActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tabbar); TabHost tabHost = getTabHost(); TabHost.TabSpec spec; Intent intent; Resources res = getResources(); intent = new Intent().setClass(this, StartActivity.class); spec = tabHost.newTabSpec("ReweHaupt").setIndicator("ReweHaupt", res.getDrawable(R.drawable.home)) .setContent(intent); tabHost.addTab(spec); intent = new Intent().setClass(this, EinkauflisteActivity.class); spec = tabHost.newTabSpec("EinkaufListe").setIndicator("EinkaufListe",res.getDrawable(R.drawable.einkaufliste)) .setContent(intent); tabHost.addTab(spec); intent = new Intent().setClass(this,FilialesuchenActivitiy.class); spec = tabHost.newTabSpec("Filiarsuchen").setIndicator("Filiarsuchen",res.getDrawable(R.drawable.searchbuton)) .setContent(intent); tabHost.addTab(spec); intent = new Intent().setClass(this,NotizblockActivity.class); spec = tabHost.newTabSpec("Notizblock").setIndicator("Notizblock",res.getDrawable(R.drawable.einkaufliste)) .setContent(intent); tabHost.addTab(spec); } </code></pre> <p><strong>EinkauflisteACtivity.java</strong></p> <pre><code> public class EinkauflisteActivity extends ActivityGroup { // das brauchen wir für groupactivity public static EinkauflisteActivity group; private ArrayList&lt;View&gt; history; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.einkaufliste); this.history = new ArrayList&lt;View&gt;(); group = this; Button btnsenden = (Button) findViewById(R.id.btnsenden); Button btnscaner = (Button) findViewById(R.id.btnscaner); Button btnsuchen = (Button) findViewById(R.id.btnsuchen); // wenn wir button clicken, rufen wir neu activity btnsuchen.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { View view = getLocalActivityManager().startActivity( "Systemhaus", new Intent(v.getContext(), SuchenActivitiy.class) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)) .getDecorView(); replaceView(view); } }); } public void replaceView(View v) { history.add(v); setContentView(v); } public void back() { if (history.size() &gt; 0) { history.remove(history.size() - 1); setContentView(history.get(history.size() - 1)); } else { finish(); } } public void onBackPressed() { back(); } public void onClick(View v) { // TODO Auto-generated method stub } </code></pre>
 

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