1

你会认为这很容易。使用此代码,我可以在列表视图中滑动多行,但我想要一次只滑动一行。如果用户选择不同的行,那么我希望旧行简单地自动重置。不知道该怎么做。这是我的代码:

在此先感谢各位..请帮助....

获取查看代码...

public View getView(int position, View convertView, ViewGroup parent) {
    View view = null;
    if(position > allModelItemsArray.size())
        return null;
    Model m = allModelItemsArray.get(position);
    final ViewHolder viewHolder = new ViewHolder();
    ViewHolder Holder = null;
    if (convertView == null) {

        view = inflator.inflate(R.layout.singlerow, null);

        view.setTag(viewHolder);

        viewHolder.text = (TextView) view.findViewById(R.id.label);
        viewHolder.text1 = (TextView) view.findViewById(R.id.label1);
        viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check);
        viewHolder.icon = (ImageView) view.findViewById(R.id.icon);
        viewHolder.checkbox.setTag(m);
        viewHolder.text.setTag(m);
        viewHolder.text1.setTag(m);
        viewHolder.icon.setTag(m);
        viewHolder.position = position;

        Holder = viewHolder;
    } else {
        view = convertView;
        Holder = ((ViewHolder) view.getTag());
    }

    if(this.listener != null)
        view.setOnTouchListener(this.listener);

    Holder.model = m;
    Holder.position = position;
    Holder.text.setText(m.getName());
    Holder.text1.setText(m.getLName());

    return view;
}
4

0 回答 0