我想爲我的列表視圖使用兩種佈局。當我滾動列表視圖時,佈局將更改爲第一個。 代碼:使用兩種佈局滾動列表視圖時更改佈局
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;
}
什麼希望仍不清楚兄弟? –
它像一個消息傳遞線程列表視圖。以一種顏色傳入消息,以另一種顏色傳出消息。 – Akhil