i have a listview and I want to use different layout if the ID is different, but I want those data to be on the same listview. example: if id="a", I want to use x1.xml layout else if id="b", I want to use x2.xml layout
this is my code:
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
String msg=arrayMsg.get(position);
ArrayList<String> splitMsg;
splitMsg=new ArrayList<String>();
StringTokenizer st=new StringTokenizer(msg,"_");
for (String token : msg.split("_")) {
splitMsg.add(token);
}
if(convertView==null){
if(splitMsg.get(0)=="allen")
convertView=View.inflate(mContext, R.layout.usermsglistview, null);
else if(splitMsg.get(0)!="allen")
convertView=View.inflate(mContext, R.layout.friendmsglistview, null);
}
if(splitMsg.get(0)=="allen"){
//do something
}
else if(splitMsg.get(0)!="allen"){
//do something
}
return convertView;
}
my problem is it seems like it keeps using the "else if(splitMsg.get(0)!="allen")" condition. So there's only one layout.