合計3つのアクティビティを持つ単純なアプリケーションを作成しています
- サインイン-ユーザー名、パスワードフィールド、サインインおよびサインアップボタンがあります
- サインアップ-さまざまなフォームフィールドと送信ボタンがあります
- メッセージ - サインインに成功すると、このアクティビティに移動します
上記の 3 つのアクティビティを定義する 3 つのタブを持つ tabhost を使用します。タブをクリックすると、それぞれのアクティビティを切り替えることができますが、フォームのボタンを使用して切り替えると、タブが表示されません。タブまたはボタンから切り替えて、画面にタブを表示したい。タブのレイアウトを維持し、フレーム内のアクティビティのみを変更するような概念はありますか...タブホストグループについて聞いたことがありますが、それを使用できません...それで可能ですか. タンク・ユー
私のタブホストコードは
public class TabActivity extends android.app.TabActivity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.tab);
/** TabHost will have Tabs */
TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
/** TabSpec used to create a new tab.
* By using TabSpec only we can able to setContent to the tab.
* By using TabSpec setIndicator() we can set name to tab. */
/** tid1 is firstTabSpec Id. Its used to access outside. */
TabSpec signinTab = tabHost.newTabSpec("tid1");
TabSpec signupTab = tabHost.newTabSpec("tid2");
TabSpec messageTab = tabHost.newTabSpec("tid3");
/** TabSpec setIndicator() is used to set name for the tab. */
/** TabSpec setContent() is used to set content for a particular tab. */
signinTab.setIndicator("Sign In").setContent(new Intent(getApplicationContext(),SignIn.class));
signupTab.setIndicator("Sign Up").setContent(new Intent(getApplicationContext(),MainActivity.class));
messageTab.setIndicator("Message").setContent(new Intent(getApplicationContext(),MessageDisplay.class));
/** Add tabSpec to the TabHost to display. */
tabHost.addTab(signinTab);
tabHost.addTab(signupTab);
tabHost.addTab(messageTab);//set Windows tab as default (zero based)
// tabHost.setCurrentTab(2);
}
}