android - ResourceNotFoundException using Spinner -


i create customized popup dialog contains spinner. dialog needs launched adapter class, below code:

 dialog dialog = new dialog(mcontext);  dialog.setcontentview(r.layout.mypopup);  spinner spinner = (spinner)dialog.findviewbyid(r.id.spinner);  arrayadapter<string> arrayadapter = new arrayadapter<string>(mcontext, 0);  arrayadapter.add("addsomestrings");  spinner.setadapter(arrayadapter);  dialog.show(); 

this code executed fine, sometime after "show()", see exception: resources$notfoundexception. last item in callstack resources.loadxmlresourceparser. if don't assign spinner using findviewbyid, instead assign via spinner = new spinner(dialog.getcontext()), don't error (but of course cannot see dialog).

mypopup layout contains:

 <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"           android:id="@+id/layout_root"           android:orientation="horizontal"           android:layout_width="fill_parent"           android:layout_height="fill_parent"           android:padding="10dp"           >   <spinner      android:id="@+id/spinner"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:drawselectorontop="true"     android:prompt="@string/group_prompt"      />  </linearlayout> 

any thoughts doing wrong? thanks!

your using array adapter constructor context , textview id, passing 0 text view resource id.

see api here : arrayadapter

try:

  arrayadapter<string> arrayadapter = new arrayadapter<string>(mcontext, android.r.layout.simple_spinner_item); 

or other resource of choice


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -