java - android- setAdapter on AlertDialog not working -
i making list of user's tumblr blogs in pop-box. of happens within handler. here code:
private class pichandler extends handler{ context c; string name; jumblrclient client; public pichandler(context context, string n, jumblrclient cl){ c=context; name = n; client = cl; } public void handlemessage(message msg) { final string[] cs = preferences.getstring("allblogs", "").split(","); (string s : cs){ log.d("drawlog", s); //logs blogs correctly } listadapter adapter = new arrayadapter<string>( getapplicationcontext(), android.r.layout.simple_selectable_list_item, cs); log.d("drawlog", (string) adapter.getitem(0)); //logs first blog correctlys new alertdialog.builder(c) .settitle("choose blog") .setmessage("choose blog publish .gif") .setadapter(adapter, new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { string root_sd = environment.getexternalstoragedirectory().tostring(); file file = new file( root_sd + "/flippy/" + name) ; if(file.exists()){ log.d("drawlog", "file exists"); //file exists log.d("drawlog", file.getpath()); } photopost post; try { post = client.newpost(cs[which], photopost.class); //photo p = new photo(); post.setdata(file); log.d("drawlog" , post.tostring()+""); post.save(); } catch (illegalaccessexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (instantiationexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } catch(nullpointerexception e){ log.d("drawlog", "null pointer wtf"); } } }).create().show(); } } all logs log right things... it's when alert displays there no list. ideas why?
you can either use setmessage() or setadapter(). mutually exclusive. if use both, message wins. solution remove setmessage() , use settitle() instead.
Comments
Post a Comment