android - How can i hide the first item when click the second item in ListView using Expandanimation? -


i using develop listview acts expandablelistview works fine 1 problem wil there when click second item first item not close

i using animation class like

expandanimation.java

public expandanimation(view view, int duration) {          setduration(duration);         manimatedview = view;         mviewlayoutparams = (layoutparams) view.getlayoutparams();          // decide show or hide view         misvisibleafter = (view.getvisibility() == view.visible);          mmarginstart = mviewlayoutparams.bottommargin;         mmarginend = (mmarginstart == 0 ? (0- view.getheight()) : 0);          view.setvisibility(view.visible);     }      @override     protected void applytransformation(float interpolatedtime, transformation t) {         super.applytransformation(interpolatedtime, t);          if (interpolatedtime < 1.0f) {              // calculating new bottom margin, , setting             mviewlayoutparams.bottommargin = mmarginstart                     + (int) ((mmarginend - mmarginstart) * interpolatedtime);              // invalidating layout, making seeing changes made             manimatedview.requestlayout();          // making sure didn't run ending before (it happens!)         } else if (!mwasendedalready) {             mviewlayoutparams.bottommargin = mmarginend;             manimatedview.requestlayout();              if (misvisibleafter) {                 manimatedview.setvisibility(view.gone);             }             mwasendedalready = true;         }     } 

expandanimationdemo.java like

public class expandanimationdemo extends activity {  //  boolean sameitemclicked=false;      boolean boolitem = false;     view previoustoolbar;     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);    //to change body of overridden methods use file | settings | file templates.         setcontentview(r.layout.main);          listview list = (listview)findviewbyid(r.id.udinilist);          // creating list adapter , populating list         arrayadapter<string> listadapter = new customlistadapter(this, r.layout.list_item);         (int i=0; i<20;i++)             listadapter.add("udini"+i);         list.setadapter(listadapter);          // creating item click listener, open/close our toolbar each item         list.setonitemclicklistener(new adapterview.onitemclicklistener() {             @suppresswarnings("unused")             public void onitemclick(adapterview<?> parent, final view view, int position, long id) {                   view toolbar = view.findviewbyid(r.id.toolbar);                  // creating expand animation item                 expandanimation expandani = new expandanimation(toolbar, 500);                  // start animation on toolbar                 toolbar.startanimation(expandani);                    }             });     }      /**      * simple implementation of list adapter.      */     class customlistadapter extends arrayadapter<string> {          public customlistadapter(context context, int textviewresourceid) {             super(context, textviewresourceid);         }          @override         public view getview(int position, view convertview, viewgroup parent) {              if (convertview == null) {                 convertview = getlayoutinflater().inflate(r.layout.list_item, null);             }              ((textview)convertview.findviewbyid(r.id.title)).settext(getitem(position));              // resets toolbar closed             view toolbar = convertview.findviewbyid(r.id.toolbar);             ((linearlayout.layoutparams) toolbar.getlayoutparams()).bottommargin = -50;             toolbar.setvisibility(view.gone);              return convertview;         }     } } 

myxml file list_item.xml

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"               android:orientation="vertical"               android:layout_width="fill_parent"               android:layout_height="fill_parent">     <textview android:id="@+id/title"               android:padding="20dip"               android:focusable="false"               android:focusableintouchmode="false"               android:layout_width="fill_parent"               android:layout_height="wrap_content"/>      <!--***********************-->     <!--*** toolbar layout ****-->     <!--***********************-->      <linearlayout android:id="@+id/toolbar"           android:layout_marginbottom="-50dip"           android:visibility="gone"           android:layout_height="50dip"           android:layout_width="fill_parent">         <button android:id="@+id/dosomething1"                 android:layout_height="50dip"                 android:focusable="false"                 android:focusableintouchmode="false"                 android:layout_width="wrap_content"                 android:text="harder"/>         <button android:id="@+id/dosomething2"                 android:layout_height="50dip"                 android:focusable="false"                 android:focusableintouchmode="false"                 android:layout_width="wrap_content"                 android:text="better"/>         <button android:id="@+id/dosomething3"                 android:layout_height="50dip"                 android:layout_width="wrap_content"                 android:focusable="false"                 android:focusableintouchmode="false"                 android:text="faster"/>         <button android:id="@+id/dosomething4"                 android:layout_height="50dip"                 android:layout_width="wrap_content"                 android:focusable="false"                 android:focusableintouchmode="false"                 android:text="stronger"/>      </linearlayout> </linearlayout> 

this developed based on link https://github.com/udinic/smallexamples/tree/master/expandanimationexample

this works fine when select second item first item not close please guide how implement requirement advance

is there solutions plz gudide me

check following.

mexpandablelistview.setongroupexpandlistener(new ongroupexpandlistener() {                      @override                     public void ongroupexpand(int groupposition) {                         int len = menuadapter.getgroupcount();                         (int = 0; < len; i++) {                             if (i != groupposition                                     && menuadapter.getchildrencount(i) > 0) {                                 mexpandablelistview.collapsegroup(i);                             }                         } }                 }); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -