1

滚动时混乱的列表视图项目。我试图在我的列表视图中实现这个想法并面临以下问题

在 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);
}
4

1 回答 1

0

一旦看到这里

   DisplayMetrics metrics = new DisplayMetrics();
   getWindowManager().getDefaultDisplay().getMetrics(metrics);
   int width = metrics.widthPixels; 

 mExpandableList = (ExpandableListView)findViewById(R.id.expandable_list);
 mExpandableList.setIndicatorBounds(width - GetPixelFromDips(50), width - GetPixelFromDips(10));  

    public int GetPixelFromDips(float pixels) {
     // Get the screen's density scale 
      final float scale = getResources().getDisplayMetrics().density;
     // Convert the dps to pixels, based on density scale
   return (int) (pixels * scale + 0.5f);
 }

看到这个工作正常

于 2013-09-30T08:28:01.917 回答