Show spinner in AlertDialog

拜拜、爱过 提交于 2019-12-05 15:28:13

You need to use alertDialog.show() to show the dialog.Also you might get error because of mContext you use there.

Often that doesn't help in dialog.Instead,try using ActivityName.this as mContext.

alertDialog.show()

inorder to view the dialog.

Unable to start activity ComponentInfo{com.example.SpinnerExample/com.example.SpinnerExample.SpinnerExampleActivity}

this means in menifest package name : com.example.SpinnerExample

and

activity name :com.example.SpinnerExample.SpinnerExampleActivity .

so remove qualified name and set ActivityName .SpinnerExample

This often happens if you give new Dialog(context); a wrong Context. Use this when building the dialog:

final Dialog dialog = new Dialog(YourClass.this);
dialog.setContentView(R.layout.your_xml_layout);
dialog.setTitle("Dialog Title");
dialog.show();

Remember to change YourClass with the class name and the XML layout path accordingly.

first your mContext have to be equals at your activity mContext = this on your onCreate, and the Spinner must be declared in your onCreate, if this solution should work for your problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!