更新时间:2023-11-23 19:47:16
我建议使用多个布局,而不是不断地重组每个行的布局。覆盖这两种方法:
I suggest using multiple layouts rather than constantly reorganizing each row's layout. Override these two methods:
@Override
public int getItemViewType(int position) {
return getItem(position).left ? 0 : 1;
}
@Override
public int getViewTypeCount() {
return 2;
}
和修改 getView()
:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(getItemViewType == 0) {
// Use the left layout
} else {
// Use the right layout
}
}