2010-12-15 8 views
1

AlertDialogでTabActivityを表示するには? 私は、TabActivityを通常のアクティビティとして実行する必要があるので、ちょっと難しいことを知っています。AlertDialogのタブアクトティビティ

Intent intent = new Intent(MyClass.this, Settings.class); 
startActivity(intent); 

ここで、設定 - TabActvivity。

AlertDialogのビューを設定することを知っている唯一の方法ですが、動作しません。

View view = (View) ((LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE)) 
    .inflate(R.layout.settings, null); 
new AlertDialog.Builder(this).setTitle("AlertDialog").setView(view).show(); 

AlertDialogでTabActivityを表示する方法はありますか?

おかげで、

答えて

4

あなたが一種のここでの見解や活動の概念をconflatingしているが、おそらく最も簡単な方法は、あなたがやりたいの代わりに、Theme.DialogにごTabActivityのテーマを設定し、それを開始することですAlertDialogを使用してActivityのポップアップ内にActivityをラップしようとしています。あなた自身の正気のために、その道をインセプションタイプの領域にしないでください。あなたはHERESに動作するサンプルコード要求してきたので、私は文句を言わない本当にこの方法をお勧めしますが、

3

EditTextでTAB1ButtonでTAB2を持って

相続タブレイアウトを、

AlertDialog

にこのレイアウトを膨らませる
<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/tabhost" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent">  
<LinearLayout 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 

<TabWidget android:id="@android:id/tabs" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
/> 

<FrameLayout android:id="@android:id/tabcontent" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <LinearLayout android:id="@+id/tab1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:layout_centerHorizontal="true" 
    > 
    <EditText 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:hint="TextBox" 
    /> 

    </LinearLayout> 
<Button android:id="@+id/tab2" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="A semi-random button" 
/> 
</FrameLayout></LinearLayout></TabHost> 

コード

AlertDialog.Builder builder=new AlertDialog.Builder(this); 
    LayoutInflater inflator=getLayoutInflater(); 
    View view=inflator.inflate(R.layout.main, null); 

    TabHost tabHost=(TabHost)view.findViewById(R.id.tabhost); 
    tabHost.setup(); 
    TabHost.TabSpec spec=tabHost.newTabSpec("tag1"); 
    spec.setContent(R.id.tab1); 
    spec.setIndicator("Clock"); 
    tabs.addTab(spec); 

    spec=tabHost.newTabSpec("tag2"); 
    spec.setContent(R.id.tab2); 
    spec.setIndicator("Button"); 
    tabs.addTab(spec); 

    builder.setView(view); 
    builder.setPositiveButton("OK", null); 
    builder.create().show(); 

私はを言ったように、これは推奨されませんAPPROACH上記ヨニSamlanによってテーマの代わりとして提案を作成します。

+0

私はインフレータのビューを持っているので、どうすればIDをsetContentに渡すことができますか? – chhameed