我試圖使用下面的代碼爲我的手機應用程序顯示AlertDialog。當我的應用程序運行到入口點時,AlertDialog沒有顯示給用戶。AlertDialog沒有出現(在後臺)
手機屏幕變成深色被鎖定。但是,我可以按手機的返回按鈕讓應用程序轉到下一步,如的行爲取消功能按下。
AlertDialog似乎隱藏在應用程序背景中。我想將它稱爲前景。
怎麼辦?
順便說一下,LogCat上沒有顯示錯誤消息。
有人可以指出我錯在哪裏,或者我可以提供哪些其他信息?
謝謝!
AlertDialog.Builder builder1 = new AlertDialog.Builder(Mainx.this);
builder1.setTitle(getResources().getString(R.string.str_sel_player));
LayoutInflater inflater = LayoutInflater.from(this);
View functionListView = inflater.inflate(R.layout.dialog_pickitem_action,null);
builder1.setView(functionListView);
mlistView = (ListView) functionListView.findViewById(R.id.m_functions_listview);
mlistView.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, mPlayers));
selDialog = builder1.create();
selDialog.show();
由於拉姆的快速一起使用的ShowDialog()反應!我的應用程序的appBackDialog的初始化是在Activity已經啓動的情況下編碼的(意味着它對於這個Activity是全局可變的)。和「appBackDialog.show();」被編碼在我的代碼的末尾。我不確定你的建議有什麼區別或擔憂? – cmh
順便說一下,我不需要DialogInterface來實現Yes/No按鈕。此AlertDialog框將僅顯示用於用戶選擇的功能頭寸列表。 – cmh
因爲我更正了發佈的代碼部分。 「appBackDialog.show();」 shound更改爲「selDialog.show();」爲我的prevouse評論。抱歉,堅固! – cmh