android - If else statement to set different listadaptor -


i'm trying set if-else statement make chat app json, want make if-else statement read json , place in labels want them be.

imagine this, "a" , chat person "b".

if message comes "b" (not me) puts message labels aligned right in listview. else - when sends message put left labels inside listview.

the strings use in statement "tag_facebook".

my listadaptor:

    listadapter adapter = new simpleadapter(this, contactlist,             r.layout.list_item, new string[] { tag_context, tag_facebook }, new int[] {                     r.id.context, r.id.facebook });  setlistadapter(adapter); 

i've tried solving using if-else statement this:

if (tag_facebook == "b"){     listadapter adapter = new simpleadapter(this, contactlist,             r.layout.list_item, new string[] { tag_context, tag_facebook }, new int[] {                     r.id.context, r.id.facebook });      setlistadapter(adapter); } else {     listadapter adapter = new simpleadapter(this, contactlist,             r.layout.list_item, new string[] { tag_context, tag_facebook }, new int[] {                     r.id.contextl, r.id.facebookl });      setlistadapter(adapter); } 

but eclipse tells me it's "dead code". how should do?

tag_facebook == "b" compare references, not string content.

use tag_facebook.equals("b").


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -