android tabgroup活動中的后退按鈕功能 - Back button functionality in android tabgroup activity -开发者知识库

android tabgroup活動中的后退按鈕功能 - Back button functionality in android tabgroup activity -开发者知识库,第1张

I have to develop back button functionality in android application.

我必須在Android應用程序中開發后退按鈕功能。

I have 4 tabs in tabgroup activity. Here i have to create the 4th tab is Go Back.

我在tabgroup活動中有4個選項卡。在這里,我必須創建第四個選項卡是返回。

Here i have to 4th tab means the 4 th tab is go to my previous activity.

這里我需要第4個標簽表示第4個標簽轉到我以前的活動。

These is my tabgroupactivity code:

這些是我的tabgroupactivity代碼:

intent = new Intent().setClass(this, MainGroupActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    // Initialize a TabSpec for each tab and add it to the TabHost
    spec = tabhost.newTabSpec("Home").setIndicator("Home", 
                    res.getDrawable(R.drawable.arrow_up_float))
                    .setContent(intent);
    tabhost.addTab(spec);

    intent = new Intent().setClass(this, CartGroupActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    // Initialize a TabSpec for each tab and add it to the TabHost
    spec = tabhost
            .newTabSpec("Cart")
            .setIndicator("Cart",
                    res.getDrawable(R.drawable.arrow_down_float))// debttab moretab
                                                        // expensestab
            .setContent(intent);
    tabhost.addTab(spec);

    intent = new Intent().setClass(this, LoginGroupActivty.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    // Initialize a TabSpec for each tab and add it to the TabHost
    spec = tabhost.newTabSpec("Login").setIndicator("Login",
                   res.getDrawable(R.drawable.btn_default_small))
                   .setContent(intent);
    tabhost.addTab(spec);
    intent = new Intent().setClass(this, GoBackActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    // Initialize a TabSpec for each tab and add it to the TabHost
    spec = tabhost
            .newTabSpec("Go Back")
            .setIndicator("Go Back",
                    res.getDrawable(R.drawable.arrow_down_float))// debttab moretab
                                                        // expensestab
            .setContent(intent);
    tabhost.addTab(spec);

Here the MainGroupActivity have 2 child class...i mean the main group activity have listview .i have to click any list means it is go to 1st child activity and have displayed listview with 4 tabs(tabgroup) in next screen.now i have to click any list in 1st child means it is go to 2nd childview and have displayed listview with 4tabs(tabgroup)..now i wish to click 4th tab(go back) in 2nd childview means its go to previous activity(1st child view)..how can i do ??? please help me...

這里MainGroupActivity有2個子類......我的意思是主要的組活動有listview。我必須點擊任何列表意味着它轉到第一個子活動並在下一個屏幕中顯示了帶有4個選項卡(tabgroup)的listview。現在我有單擊第一個孩子中的任何列表意味着它轉到第二個子視圖並顯示listview with 4tabs(tabgroup)..現在我想在第二個子視圖中單擊第四個選項卡(返回)意味着它轉到上一個活動(第一個子視圖) ..我能怎么做 ???請幫我...

How can i write the condition for 4th tab.please give me code for these purpose.

我怎么能寫第4個標簽的條件。請給我代碼用於這些目的。

1 个解决方案

#1


0  

you can use

您可以使用

Intent intent = new Intent( v.getContext(), YourOtherActivity.class);
   startActivity(intent);}

` now when the user click tab it will automatically take the user to your other activity.

`現在,當用戶點擊標簽時,它會自動將用戶帶到您的其他活動。

最佳答案:

本文经用户投稿或网站收集转载,如有侵权请联系本站。

发表评论

0条回复