i ‘m going to develop an app like a chat messenger
Everytime i send a text, it will appear on the left side and a reply will appear on the right side of the listview
I have already done it by using the custom layout of the odd and even position of items
So when the item is the odd position, it will appear on the left and the even will on the right.
by extended the BaseAdapter
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = getLayoutInflater();<br>
View row;<br>
if (position % 2 == 0) {<br>
row = inflater.inflate(R.layout.list_row_layout_even,parent,false);
TextView textLabel = (TextView) row.findViewById(R.id.text);
textLabel.setText(arraylist.get(position));
} else {
row = inflater.inflate(R.layout.list_row_layout_odd, parent,
false);
TextView textLabel = (TextView) row.findViewById(R.id.text);
textLabel.setText(arraylist.get(position));
}
return (row);
}
But now, i want to put it on the side which i want, i mean the position have to independent with the position of the item because sometime, one person can keep sending message, so it must appear on the same side not each side like the old layout.
Is it possible to do that ? any help will be very appreciated !
Thanks
Yes this can be acheived by simply maintain an variable whehter the message is received from person and make the same variable to false if it was not received from that person.
Then just check that variable and do your task as needed instead of odd and even positions.