是否有任何方法可以在MainActivity中調用alertbox,而無需爲其設置佈局。我有一個MainActivity和一個AlertboxActivity,但我不希望AlertboxActivity的xml佈局。我只想調用並執行de main.xml中的代碼Alertdialog without contentview
0
A
回答
2
如上面的註釋所述。你只是想做一個對話框? 您可以使用父視圖輕鬆創建視圖。例如!您的main_activity_layout.xml 包含根「容器」佈局。 IE相對佈局等。給根佈局一個ID,然後在你的主要活動中啓動它。 IE RelativeLayout myLayout = (RelativeLayout)findViewById(R.Id.MYID);
接下來爲它添加一個視圖。 myLayout.addView(new LinearLayout()
)..等等...
AlertDialog dialog = new AlertDialog.Builder(getApplicationContext())
.setMessage("MY ALERT MESSAGE")
.setTitle("MY TITLE")
.setNegativeButton("NO BUTTON", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.setPositiveButton("YES BUTTON", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.create();
//and to show
dialog.show();
相關問題
- 1. AlertDialog setSingleChoice without radio buttons
- 2. 怎樣的AlertDialog
- 3. listener for contentView
- 4. 無法設置contentview
- 5. contentView標記問題
- 6. Android獲取contentView ID
- 7. AlertDialog後的AlertDialog
- 8. getIntent without extend活動
- 9. AlertDialog內alertdialog安卓
- 10. AlertDialog不起作用
- 11. 組合兩個ContentView的
- 12. iOS中的ContentView V/S SuperView?
- 13. 自定義UICollectionViewCell contentView動畫
- 14. UITableView reorderControl(或contentView)寬度
- 15. UIScrollView的ContentView中的UIViewControllers?
- 16. UITableViewCell - 滾動時ContentView重疊
- 17. 將文本設置爲ContentView
- 18. 更改片段contentView android
- 19. 將contentView集中到UIPopoverController中
- 20. contentView子視圖中的UITableViewCell
- 21. Hosting Silverlight without IIS
- 22. stop project without debugging
- 23. redshift to_timestamp()without millisecond
- 24. SyncVar without NetworkServer.Spawn
- 25. jQuery datatable without bootstrap
- 26. $ _POST ['variable'] without
- 27. For loop without switch
- 28. Gateway + ServiceActivator without poller
- 29. PresentViewController without fullscreen
- 30. 使用_.without
你只是想表明一個簡單AlertDialog,是嗎? – joao2fast4u 2014-09-30 00:54:44