1

jumbled listview item while scrolling. I'm trying to implement this idea in my listview and facing the following issue

Under Onitemclick() last visisble view is closed and new view is shown, its working but when first item is visible and after scrolling the listview I see other item are also visible without user clicks. Any suggestion how to keep the only one item visible while scrolling.

Actitvity:

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;

}

Adapter class:

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);
}
Community
  • 1
  • 1
user755
  • 2,521
  • 3
  • 18
  • 29

1 Answers1

0

once see here

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

see this one working fine

Community
  • 1
  • 1
NagarjunaReddy
  • 8,621
  • 10
  • 63
  • 98