且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

AlertDialog并未(在背景中)

更新时间:2023-01-23 21:46:18

这是奇怪的。

您可以尝试使用的ShowDialog()连同onCreateDialog()

覆盖活动的

对话框onCreateDialog(INT ID)

然后调用的ShowDialog(INT ID)

I attempted to show an AlertDialog for my phone application using the code below. While my application ran to the entry point, the AlertDialog did not show up for user.

The phone screen changed to a dark color was locked. However, I can press phone's Back button to let the application go to next step like the behavior of Cancel function pressed.

The AlertDialog seems hidden in the application background. I would like to call it to foreground.

How to do it ?

By the way, there was no error message shown on the LogCat.

Could somebody point me out where I was wrong or what other information I can provide?

Thanks !

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();

It is strange.

You can try to use showDialog() together with onCreateDialog()

override Activity's

Dialog onCreateDialog(int id)

then invoke showDialog(int id)