Android 在警报框中创建表格布局
在我的应用程序中,我想创建一个带有选项卡布局的警报框。 是否可以在警报框中创建选项卡布局?? 请帮帮我,给我一个合适的解决方案。Android 在警报框中创建表格布局,android,android-layout,android-tablelayout,Android,Android Layout,Android Tablelayout,在我的应用程序中,我想创建一个带有选项卡布局的警报框。 是否可以在警报框中创建选项卡布局?? 请帮帮我,给我一个合适的解决方案。 提前谢谢 您可以创建自定义警报对话框 final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.YOURDIALOGTHEME)); alertDialogBuilder.setCancelab
提前谢谢 您可以创建自定义警报对话框
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.YOURDIALOGTHEME));
alertDialogBuilder.setCancelable(false);
alertDialogBuilder.setTitle(title);
alertDialogBuilder.setMessage(message);
LayoutInflater factory = LayoutInflater.from(this);
final View alertView = factory.inflate(R.layout.mycustomtabinalert, null);
alertDialogBuilder.setView(alertView);
mycustomtabinalert.xml是一个布局文件,您可以在其中创建选项卡布局
根据需要为警报对话框指定正按钮和负按钮
alertDialogBuilder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
}
}
有关创建选项卡的信息,请参阅文章您可以根据需要创建具有表布局的xml。下面是来自的表格布局示例 请检查一下并告诉我结果
谢谢您所做的尝试??我想在一个警报框中的多个选项卡中显示内容。您可以对其进行自定义布局并在AlertDialog中充气。转到自定义对话框GetTabHost()时出错,因为我扩展了活动而不是TabActivity
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shrinkColumns="*" android:stretchColumns="*" android:background="#ffffff">
<!-- Row 1 with single column -->
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent" android:layout_height="wrap_content"
android:textSize="18dp" android:text="Row 1" android:layout_span="3"
android:padding="18dip" android:background="#b0b0b0"
android:textColor="#000"/>
</TableRow>
<!-- Row 2 with 3 columns -->
<TableRow
android:id="@+id/tableRow1"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<TextView
android:id="@+id/TextView04" android:text="Row 2 column 1"
android:layout_weight="1" android:background="#dcdcdc"
android:textColor="#000000"
android:padding="20dip" android:gravity="center"/>
<TextView
android:id="@+id/TextView04" android:text="Row 2 column 2"
android:layout_weight="1" android:background="#d3d3d3"
android:textColor="#000000"
android:padding="20dip" android:gravity="center"/>
<TextView
android:id="@+id/TextView04" android:text="Row 2 column 3"
android:layout_weight="1" android:background="#cac9c9"
android:textColor="#000000"
android:padding="20dip" android:gravity="center"/>
</TableRow>
<!-- Row 3 with 2 columns -->
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal">
<TextView
android:id="@+id/TextView04" android:text="Row 3 column 1"
android:layout_weight="1" android:background="#b0b0b0"
android:textColor="#000000"
android:padding="20dip" android:gravity="center"/>
<TextView
android:id="@+id/TextView04" android:text="Row 3 column 2"
android:layout_weight="1" android:background="#a09f9f"
android:textColor="#000000"
android:padding="20dip" android:gravity="center"/>
</TableRow>
</TableLayout>
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.anyOfYourDialogTheme));
alertDialogBuilder.setCancelable(false);
alertDialogBuilder.setTitle(title);
alertDialogBuilder.setMessage(message);
LayoutInflater mFactory = LayoutInflater.from(this);
View mView = mFactory.inflate(R.layout.CustomTableLayout, null);
alertDialogBuilder.setView(mView);