Listview item is not aligned properly

klow

New Member
I have created on chat screen and i want to display sent message on left side and received messages right side.
To do this i have created two xml one for right and one for left and i have bind this two xml with adapter.
The problem is that when i am sending a text it resides on left side and when i am receiving a text,the sent text is also aligned on right side.and when i am sending again then whole text(chat) aligns on left.Here is my ArrayAdapter:\[code\]private void setListAdapterL() { ArrayAdapter<String> adapterL = new ArrayAdapter<String>(this, R.layout.row_left, messages); mList.setAdapter(adapterL);}private void setListAdapterR() { // TODO Auto-generated method stub ArrayAdapter<String> adapterR = new ArrayAdapter<String>(this, R.layout.row_right, messages); mList.setAdapter(adapterR);}\[/code\]My xml file for row_right.xml.in other row_left.xml just gravity is changed:\[code\]<?xml version="1.0" encoding="utf-8"?><TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" android:minHeight="?android:attr/listPreferredItemHeight" android:paddingLeft="5dip" />\[/code\]Any ideas and suggestion will be appreciated.
Thanks
 
Back
Top