Building a simple Group Chat View in Android -


i'm building simple online chat room app. have achieved below right now:

robert:blah.. tom: yes blah.. david(you): sounds cool! lily: know blah... robert:blah.. robert:blah.. david(you): wow! blah...  

the new feature/problem i'm facing want current user's talks show on right. below(this david see on screen):

robert:blah.. tom: yes blah..                                   sounds cool! : david(you) lily: know blah... robert:blah.. robert:blah..                                        wow! blah... : david(you) 

each line above textview, , i'm dynamically creating textview whenever there's new message, adding them linearlayout contains these textview. in order make david(current user)'s talk on right, tried set align right , change linearlayout relativelayout. realize once use relativelayout, talks in same line overlapping each other since didn't set height.. can shed light on how achieve please? codes below:

...     //new messages stored in lines[] (int = 0; < lines.length; i++) {      textview newline = new textview(getbasecontext());      newline.settext(lines[i]);      // check if speaker of line user himself                 if (speakername.equals(username)) {      //change layout of textview make align right..      }     mylinearview.addview(newline);//add linearview contains these talks  } 

you need use listview, chor waichun mentioned. however, way relative layout set relativelayout.layoutparams view rule sets layout_below previous view. in xml.

also, if insist on adding 1 view per line (which stated wrong, use listview), there's no reason not use linearlayout. can have linearlayout right justified text, set gravity right.


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 -

CSS3 Transition to highlight new elements created in JQuery -