我有一個tabactivity和grouptactivty中的後退按鈕的問題。 我有4個選項卡,在選項卡中我也有更多3個活動。當我打電話給一個活動時,這是沒有問題的。但如果我點擊後退按鈕,比我的應用程序接近完成。TabActivity GroupActivity返回按鈕不工作
這是我的代碼。我的福爾特在哪裏?
Tabactivity
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, HauptmenuActivity.class);
spec = tabHost.newTabSpec("ReweHaupt")
.setIndicator("ReweHaupt",
res.getDrawable(R.drawable.home))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, ContactGroupEinkaufliste.class);
spec = tabHost
.newTabSpec("EinkaufListe")
.setIndicator("EinkaufListe",
res.getDrawable(R.drawable.einkaufliste))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, FilialesuchenActivity.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("Einkaufzettel")
.setIndicator("Einkaufzettel",
res.getDrawable(R.drawable.einkaufliste))
.setContent(intent);
tabHost.addTab(spec);
}
ContactGroupEinkaufliste.java
public class ContactGroupEinkaufliste extends ActivityGroup {
public static ContactGroupEinkaufliste groupContact;
private ArrayList<View> history;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.history = new ArrayList<View>();
groupContact = this;
View view = getLocalActivityManager().startActivity(
"idHoraireActivity",
new Intent(this, EinkauflisteActivity.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() > 0) {
history.remove(history.size()-1);
setContentView(history.get(history.size()-1));
}else {
finish();
}
}
// @Override
public void onBackPressed() {
ContactGroupEinkaufliste.groupContact.back();
return;
}}
EinkauflisteActivity.java
public class EinkauflisteActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.einkaufliste);
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 = ContactGroupEinkaufliste.groupContact
.getLocalActivityManager()
.startActivity(
"suchenactivity",
new Intent(v.getContext(), SuchenActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
.getDecorView();
ContactGroupEinkaufliste.groupContact.replaceView(view);
}
});
}}
SuchenActivity.java
public class SuchenActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.suchen);
}}
謝謝
對不起,但我還沒有找到。這究竟在哪裏?您是指 – Lucky