0

アプリケーションでアクティビティ グループでタブバーを使用しました。ホーム、在庫、citn、記事のような 4 つのタブがあります。私のアプリケーションでは、最初にホームページからホームページを表示し、ユーザーが webview をクリックすると、homepage1 アクティビティに移動します。ホームページから 1 アクティビティ ユーザーが [ストック] タブをクリックすると、ストック アクティビティに移動します。株式活動のユーザーから [ホーム] タブをクリックすると、homepage1 活動に移動します。家でのアクティビティを表示したいのですが、どのようにすればよいですか?

私の質問は、最後のアクティビティを表示するアクティビティ グループを使用してタブを切り替えることです。最初のアクティビティを表示しますか?

わかりました、コードを添付します

spec = tabHost.newTabSpec("FirstGroup").setIndicator("FirstGroup",   
                getWallpaper()).setContent( new Intent(this,FirstGroup.class));
        tabHost.addTab(spec);   

View view = getLocalActivityManager().startActivity("CitiesActivity", new Intent(this,CitiesActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET )).getDecorView();

          // Replace the view of this ActivityGroup   
      replaceView(view);   

   }   

public void replaceView(View v) {   
            // Adds the old one to history   
    history.add(v);   
            // Changes this Groups View to the new View.   
    setContentView(v);

この例を実行して ください http://united-coders.com/nico-heid/use-android-activitygroup-within-tabhost-to-show-different-activity

アクティビティとタブの切り替え

Pastebin に投稿しました。私のリンクは http://pastebin.com/1zG0HJgvです。

4

1 に答える 1

1

こんにちは、以下に示すようにタブ変更イベントを試しましたか

tabHost.addTab(tabHost.newTabSpec("tab1").setContent(
                R.id.content_movies).setIndicator("",
                getResources().getDrawable(R.drawable.icon)));
        tabHost.addTab(tabHost.newTabSpec("tab2").setContent(
                new Intent(this, Sample.class)).setIndicator("",
                getResources().getDrawable(R.drawable.menu_icon)));
    tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {

       @Override
       public void onTabChanged(String arg0) {


         if(arg0.equals("tab1"))
        {

       /*write the code here to show the view 
     Currentclass, the class where you have used ontabchanged function and 
     Newclass is the class where you want to navigate*/
           Intent obj_intent = new Intent(CureentClass.this,Newclass.class);
    startActivity(obj_intent);

        }

        else if (arg0.equals("tab2")) {

                 // write the code here to show the view 
       }
       //similarly for other tabs
      });
于 2010-12-06T09:20:50.023 に答える