我正在尝试为我的列表视图使用两种布局。当我滚动列表视图时,布局更改为第一个。编码:
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View vi = convertView;
if (convertView == null) fll = flag.get(position);
if(fll.equals("I")) {
vi = inflater.inflate(R.layout.conersation_replay, null);
TextView t1 = (TextView)vi.findViewById(R.id.mess1);
TextView t2 = (TextView)vi.findViewById(R.id.name1);
TextView t3 = (TextView)vi.findViewById(R.id.time1);
t1.setText(message.get(position));
t2.setText(name);
t3.setText(time.get(position));
}
else {
vi = inflater.inflate(R.layout.conversation_custome, null);
TextView t1 = (TextView)vi.findViewById(R.id.mess);
TextView t2 = (TextView)vi.findViewById(R.id.name);
TextView t3 = (TextView)vi.findViewById(R.id.time);
t1.setText(message.get(position));
t2.setText(name);
t3.setText(time.get(position));
}
return vi;
}