Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java AlertDialog中的Android选项卡活动_Java_Android_Tabs_Android Activity_Android Intent - Fatal编程技术网

Java AlertDialog中的Android选项卡活动

Java AlertDialog中的Android选项卡活动,java,android,tabs,android-activity,android-intent,Java,Android,Tabs,Android Activity,Android Intent,如何在AlertDialog中显示TabActivity? 我知道这有点棘手,因为我们应该像正常活动一样运行TabActivity e、 g 其中设置-TabActvivity 我知道的唯一方法是为AlertDialog设置视图,但它不起作用 View view = (View) ((LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.settings, null); new AlertDi

如何在AlertDialog中显示TabActivity? 我知道这有点棘手,因为我们应该像正常活动一样运行TabActivity

e、 g

其中设置-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


谢谢,

您在这里混淆了视图和活动的概念,但可能最简单的方法是设置TabActivity的主题并启动它,而不是使用AlertDialog并尝试将活动包装在另一个活动的弹出窗口中。为了你自己的理智,不要沿着这条路走到《盗梦空间》类型的领域。

你在这里混淆了视图和活动的概念,但可能最简单的方法是设置TabActivity的主题并启动它,而不是使用AlertDialog并尝试将一个活动包装在另一个活动的弹出窗口中。为了你自己的理智起见,不要沿着这条路走到《盗梦空间》类型的领域。

我不推荐这种方法,但既然你已经要求了这种行为,这里有一个示例代码:

这是一个选项卡布局,在选项卡1中有一个EditText,在选项卡2中有一个按钮


正如我所说的,这不是推荐的方法,而是按照上面Yoni Samlan的建议创建一个主题。

我不推荐这种方法,但因为您已经请求了该行为,这里有一个示例代码:

这是一个选项卡布局,在选项卡1中有一个EditText,在选项卡2中有一个按钮


正如我所说,这不是推荐的方法,而是按照上面Yoni Samlan的建议创建一个主题。

如果我有充气器视图,那么我如何将ID传递给setContent?如果我有充气器视图,那么我如何将ID传递给setContent?
View view = (View) ((LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE))
  .inflate(R.layout.settings, null);
new AlertDialog.Builder(this).setTitle("AlertDialog").setView(view).show();
<?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();