在我的應用程序中,我想創建一個帶有選項卡布局的警告框。 是否可以在警報框中創建一個選項卡布局? 請幫我一把。給出一個合適的解決方案。 在此先感謝!在警告框中創建一個tablayout
0
A
回答
0
您可以創建自定義警報對話框。
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) {
}
}
要創建標籤,請參考文章here
1
您可以創建表格佈局的XML像你想要的。下面有來自here
<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>
表格佈局的一個例子,你可以擡高這個XML到您的警告對話框。
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);
請檢查出來,讓我知道結果。
謝謝
相關問題
- 1. 在RML報告中創建一個框
- 2. 在R中創建警告
- 3. 如何在android的主類的子類中創建一個警告對話框?
- 4. 在Resharper中創建自己的警告?
- 5. 在警告框
- 6. tablayout在另一個tablayout
- 7. 如何創建一個警報,在一個集中的警報
- 8. 是否有可能創建一個非中心的JavaScript警告框?
- 9. 如何在android中創建一個警報對話框?
- 10. 看一個警告對話框
- 11. 無法在XML中創建TabLayout
- 12. 警告在XML創建形狀時
- 13. 警告僅在一個類
- 14. 多個警告對話框
- 15. 在按下一個鏈接來顯示一個JavaScript警告框
- 16. 警告框HTML
- 17. 警告一個TabActivity
- 18. 如何正確創建一個Tablayout現在Tabactivity已被棄用?
- 19. 警告:請創建一個apidoc.json配置文件
- 20. 創建一個沒有警告的位圖
- 21. 拒絕警告:您正試圖在Rails 3.2.8中創建一個屬性'info'
- 22. 創建tabLayout時拋出NullPointerException
- 23. 在警告對話框
- 24. 無法在警告框
- 25. 在html中創建一個登錄框
- 26. 創建組合框9x9網格時的警告
- 27. 如何創建打開警告框的輸入表單?
- 28. JQuery的瀏覽器是否=即創建警告框
- 29. 如何在警報視圖中創建兩個文本框,IOS
- 30. 創建在Crystal Reports中設置參數之前出現的警告提示框
你試過什麼? –
我想在警告框中的多個選項卡中顯示內容。 – user2603471
您可以爲其定製佈局並在AlertDialog中膨脹。 – Piyush