我有一个 multicolumn_listview。某些行在列表视图中重复。我查看了有关此问题的所有解决方案。
- Listview 高度不是 wrap_content
- 我的持有人类静态
- 我
if(convertView==null)
在 getview 方法中创建了块中的所有视图。
但问题还没有解决..请帮助我..
这是我的适配器类;
public class ListViewAdapterCurrentList extends BaseAdapter
{
public ArrayList<HashMap<String, String>> list;
boolean isDetail = false;
private String currentNo;
private String currentCode;
private String currentName;
private String date;
private String status;
private Activity activity;
private Boolean isPlan = true;
public ListViewAdapterCurrentList(Activity activity, ArrayList<HashMap<String, String>> list, boolean isPlan) {
super();
this.activity = activity;
this.list = list;
this.isPlan = isPlan;
}
@Override
public int getCount()
{
return list.size();
}
@Override
public Object getItem(int position)
{
return list.get(position);
}
@Override
public long getItemId(int position)
{
return 0;
}
static class ViewHolder
{
ImageView currentDetail;
TextView currentNo;
TextView currentCode;
TextView currentName;
TextView date;
TextView durum;
LinearLayout linearLayoutCurrentBase;
LinearLayout linearLayoutCurrentDetail;
TextView currentAddress;
TextView currentPhone;
TextView currentManager;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
final ViewHolder holder;
LayoutInflater inflater = activity.getLayoutInflater();
final HashMap<String, String> map = list.get(position);
if (convertView==null)
{
Log.d("CL:getView()", "Fetching Row: " + position);
convertView = inflater.inflate(R.layout.currentlistitems, parent, false);
holder = new ViewHolder();
holder.currentDetail = (ImageView) convertView.findViewById(R.id.imageViewCurrentListDetail);
holder.currentNo = (TextView) convertView.findViewById(R.id.textViewCurrentListNo);
holder.currentCode = (TextView) convertView.findViewById(R.id.textViewCurrentListCode);
holder.currentName = (TextView) convertView.findViewById(R.id.textViewCurrentListName);
holder.date = (TextView) convertView.findViewById(R.id.textViewCurrentListDate);
holder.durum = (TextView) convertView.findViewById(R.id.textViewCurrentListStatus);
holder.linearLayoutCurrentBase = (LinearLayout) convertView.findViewById(R.id.layoutBaseCurrentList);
holder.linearLayoutCurrentDetail = (LinearLayout) convertView.findViewById(R.id.layoutDetailCurrentList);
holder.currentAddress = (TextView) convertView.findViewById(R.id.textViewCurrentAddress);
holder.currentPhone = (TextView) convertView.findViewById(R.id.textViewCurrentPhone);
holder.currentManager = (TextView) convertView.findViewById(R.id.textViewCurrentManager);
convertView.setTag(holder);
} else
{
holder = (ViewHolder) convertView.getTag();
}
currentNo = map.get("CariNo");
currentCode = map.get("CariKod");
currentName = map.get("CariUnvan");
date = map.get("Tarih");
status = map.get("Durum");
holder.currentDetail.setBackgroundResource(R.drawable.box_plus);
holder.currentNo.setText(currentNo);
holder.currentCode.setText(currentCode);
holder.currentName.setText(currentName);
holder.date.setText(date);
holder.durum.setText(status);
if (!isPlan)
{
holder.durum.setVisibility(View.GONE);
holder.date.setVisibility(View.GONE);
holder.currentName.setWidth(300);
}
initDetailInfo(holder.currentAddress, holder.currentPhone, holder.currentManager, currentNo);
holder.currentDetail.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
if (!isDetail)
{
holder.linearLayoutCurrentDetail.setVisibility(View.VISIBLE);
holder.currentDetail.setBackgroundResource(R.drawable.box_delete_expand);
isDetail = true;
} else
{
holder.linearLayoutCurrentDetail.setVisibility(View.GONE);
holder.currentDetail.setBackgroundResource(R.drawable.box_plus);
isDetail = false;
}
}
});
return convertView;
}