在我的SimepleAdapter中的getView函数中,位置在达到7后重置为零,这使得我的ListView在项目编号8之后重复列表。 我在这里发现了许多线程,但没有解决我的问题:
@Override
public View getView(final int position, View convertView,final ViewGroup parent)
{
if (convertView == null)
{
convertView = super.getView(position, convertView, parent);
wrapper = new YourWrapper (convertView);
convertView.setTag(wrapper);
}
else
wrapper = (YourWrapper) convertView.getTag();
return convertView;
}
这是我的YourWrapper类:
public class YourWrapper
{
private View base;
private Button button;
public YourWrapper(View base)
{
this.base = base;
}
public Button getButton()
{
if (button == null)
{
button = (Button) base.findViewById(R.id.tv_button);
}
return (button);
}
}