滚动时混乱的列表视图项目。我试图在我的列表视图中实现这个想法并面临以下问题
在 Onitemclick() 下,最后一个可见视图关闭并显示新视图,它的工作但当第一个项目可见并且滚动列表视图后,我看到其他项目也可见,无需用户点击。任何关于如何在滚动时保持唯一一项可见的建议。
活动:
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
View last_dropdownBarview=null;
ViewHolder holder = (ViewHolder) arg1.getTag();
final View dropDown = holder.dropdownBarview;
if(last_dropdownBarview!=null)
{
last_dropdownBarview.setVisibility(View.GONE);
}
ExpandCollapseAnimation.setHeightForWrapContent(MainActivity.this, dropDown);
ExpandCollapseAnimation expandAni = new ExpandCollapseAnimation(dropDown, DROP_DOWN_TIME);
dropDown.startAnimation(expandAni);
last_dropdownBarview= dropDown;
}
适配器类:
static class ViewHolder {
.
.
protected View dropdownBarview;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder = null;
if (convertView == null) {
LayoutInflater inflator = context.getLayoutInflater();
convertView = inflator.inflate(R.layout.row, null);
viewHolder = new ViewHolder();
viewHolder.dropdownBarview= convertView.findViewById(R.id.toolbar);
convertView.setTag(viewHolder);
convertView.setTag(R.id.dropdownbar,viewHolder.dropdownBarview);
}
else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.dropdownBarview.setTag(position);
}