title: I need animation in ExpandableLIstView in onGroupExpand and onGroupCollapse
body: <p>I am new in android and badly need to do animation in ExpandableLIstView in onGroupExpand and onGroupCollapse.</p>
  
  <p>Please help me.</p>
  
  <p>Given below is my code -</p>
  
  <p>My MainActivity is</p>
  
  <pre><code>package comsam.myexpandablelistviedjsonapp;
  
  import android.app.ProgressDialog;
  import android.net.ParseException;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.support.v4.view.animation.PathInterpolatorCompat;
  import android.support.v7.app.AppCompatActivity;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.animation.AccelerateInterpolator;
  import android.view.animation.Animation;
  import android.view.animation.Interpolator;
  import android.view.animation.TranslateAnimation;
  import android.widget.ExpandableListView;
  import android.widget.ImageView;
  import android.widget.Toast;
  
  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.methods.HttpGet;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.apache.http.util.EntityUtils;
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import java.io.IOException;
  import java.util.ArrayList;
  
  public class MainActivity extends AppCompatActivity {
  
      private ExpandListAdapter ExpAdapter;
      private ExpandableListView ExpandList;
  
      private Interpolator easeInOutQuart = PathInterpolatorCompat.create(0.77f, 0f, 0.175f, 1f);
  
      private int lastExpandedPosition = -1;
  
      ArrayList&lt;Parent&gt; list = new ArrayList&lt;Parent&gt;();
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          final ImageView animatedButton = (ImageView) findViewById(R.id.parent_img);
          ExpandList = (ExpandableListView)findViewById(R.id.exp_list);
          new JSONAsyncTask().execute("http://local.agdits.com.bd/hrdemo/expandable.php");
  
         ExpAdapter = new ExpandListAdapter(MainActivity.this, list);
  
          ExpandList.setAdapter(ExpAdapter);
  
  
          //to show which list has been clicked for Expand
  
  
          ExpandList.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
  
              @Override
              public void onGroupExpand(final int groupPosition) {
                  if (lastExpandedPosition != -1 &amp;&amp; groupPosition != lastExpandedPosition) {
                      ExpandList.collapseGroup(lastExpandedPosition);
                      // setupLayoutAnimationClose(groupPosition);
                      // new AnimUtils().collapse(ExpandList);
                  }
                  lastExpandedPosition = groupPosition;
  
  
              }
  
  
          });
  
  
          //to show which list has been clicked for Collapse
          ExpandList.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
  
              @Override
              public void onGroupCollapse(int parentPosition) {
                  Toast.makeText(getBaseContext(), ExpAdapter.getGroupName(parentPosition) + " is collapse ", Toast.LENGTH_LONG).show();
  
              }
          });
  
          //to show which Child has been clicked
          ExpandList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
              @Override
              public boolean onChildClick(ExpandableListView parent, View v, int parentPosition, int childPosition, long id) {
  
                  Toast.makeText(getBaseContext(), ExpAdapter.getChildName(parentPosition, childPosition) + " from category " + ExpAdapter.getGroupName(parentPosition) + " is selected", Toast.LENGTH_LONG).show();
                  return false;
              }
          });
  
  
  
  
  
      }
  
  
  
      private void expand1() {
          System.out.println("I am here expand");
  
      }
  
      private void collapse() {
          System.out.println("I am here collapse");
      }
  
  
  
  
      class JSONAsyncTask extends AsyncTask&lt;String, Void, Boolean&gt; {
  
          ProgressDialog dialog;
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              dialog = new ProgressDialog(MainActivity.this);
              dialog.setMessage("Loading, please wait");
              dialog.setTitle("Connecting server");
              dialog.show();
              dialog.setCancelable(false);
          }
  
          @Override
          protected Boolean doInBackground(String... urls) {
              try {
  
                  //------------------&gt;&gt;
                  HttpGet httppost = new HttpGet(urls[0]);
                  HttpClient httpclient = new DefaultHttpClient();
                  HttpResponse response = httpclient.execute(httppost);
  
                  // StatusLine stat = response.getStatusLine();
                  int status = response.getStatusLine().getStatusCode();
  
                  if (status == 200) {
                      HttpEntity entity = response.getEntity();
                      String data = EntityUtils.toString(entity);
  
                      //System.out.println(data);
  
                      ArrayList&lt;Child&gt; ch_list;
  
                      JSONArray jsonArray1 = new JSONArray(data);
  
                      for (int i = 0; i &lt; jsonArray1.length(); i++) {
                          JSONObject object = jsonArray1.getJSONObject(i);
                          // System.out.println(object.getString("_id"));
                          Parent parent = new Parent();
                          parent.setParentName(object.getString("CategoryName"));
                          parent.setParentImage(object.getString("CatImage"));
                          //System.out.println(object.getString("CategoryName"));
  
                          //Make Child List Array
                          ch_list = new ArrayList&lt;Child&gt;();
                          JSONArray childArray = object.getJSONArray("child");
                          //System.out.println(childArray.length());
                          for (int j = 0; j &lt; childArray.length(); j++) {
  
                              JSONObject childobject = childArray.getJSONObject(j);
  
                              Child child = new Child();
  
                              child.setName(childobject.getString("name"));
                              child.setImage(childobject.getString("image"));
  
                              ch_list.add(child);
                          }
  
                         // System.out.println(childArray);
                          //Child List to Parent Items
                          parent.setItems(ch_list);
  
                          list.add(parent);
  
  
                      }
                      return true;
                  }
  
                  //------------------&gt;&gt;
  
  
  
              } catch (ParseException e) {
                  e.printStackTrace();
              } catch (IOException e) {
                  e.printStackTrace();
              } catch (JSONException e) {
                  e.printStackTrace();
              }
              return false;
          }
  
          protected void onPostExecute(Boolean result) {
              dialog.cancel();
              ExpAdapter.notifyDataSetChanged();
              if(result == false) {
                 Toast.makeText(getApplicationContext(), "Unable to fetch data from server", Toast.LENGTH_LONG).show();
              }
  
          }
      }
  
  
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu_main, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
  
          //noinspection SimplifiableIfStatement
          if (id == R.id.action_settings) {
              return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  }
  </code></pre>
  
  <p>My ExpandListAdapter class is</p>
  
  <pre><code>package comsam.myexpandablelistviedjsonapp;
  
  import android.content.Context;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.os.AsyncTask;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseExpandableListAdapter;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  import java.io.InputStream;
  import java.util.ArrayList;
  
  
  /**
   * Created by tanvinn on 10/27/2015.
   */
  public class ExpandListAdapter extends BaseExpandableListAdapter{
  
      private Context context;
      private ArrayList&lt;Parent&gt; parents;
      public MainActivity activity;
      public ImageLoader imageLoader;
      public int lastExpandedGroupPosition=-1;
  
      public ExpandListAdapter(Context context, ArrayList&lt;Parent&gt; parents) {
          this.context = context;
          this.parents = parents;
  
          // Create ImageLoader object to download and show image in list
          // Call ImageLoader constructor to initialize FileCache
          imageLoader = new ImageLoader(activity);
      }
  
      @Override
      public Object getChild(int parentPosition, int childPosition) {
          ArrayList&lt;Child&gt; chList = parents.get(parentPosition).getItems();
          return chList.get(childPosition);
      }
  
      @Override
      public long getChildId(int parentPosition, int childPosition) {
          return childPosition;
      }
  
      @Override
      public View getChildView(int parentPosition, int childPosition,
                               boolean isLastChild, View convertView, ViewGroup parent) {
  
          Child child = (Child) getChild(parentPosition, childPosition);
          if (convertView == null) {
              LayoutInflater infalInflater = (LayoutInflater) context
                      .getSystemService(context.LAYOUT_INFLATER_SERVICE);
              convertView = infalInflater.inflate(R.layout.child_layout, null);
          }
  
  
          TextView tv = (TextView) convertView.findViewById(R.id.child_txt);
          ImageView imageView = (ImageView)convertView.findViewById(R.id.child_img);
          imageView.setImageResource(R.drawable.geofence1);
  
  
          tv.setText(child.getName().toString());
          //new DownloadImageTask(imageView).execute(child.getImage().toString());
          imageLoader.DisplayImage(child.getImage().toString(), imageView);
  
  
  
          return convertView;
      }
  
      @Override
      public int getChildrenCount(int parentPosition) {
          ArrayList&lt;Child&gt; chList = parents.get(parentPosition).getItems();
          return chList.size();
      }
  
      @Override
      public Object getGroup(int parentPosition) {
          return parents.get(parentPosition);
      }
  
      @Override
      public int getGroupCount() {
          return parents.size();
      }
  
      @Override
      public long getGroupId(int parentPosition) {
          return parentPosition;
      }
  
      @Override
      public View getGroupView(int parentPosition, boolean isExpanded,
                               View convertView, ViewGroup parent) {
          Parent parent1 = (Parent) getGroup(parentPosition);
          if (convertView == null) {
              LayoutInflater inf = (LayoutInflater) context
                      .getSystemService(context.LAYOUT_INFLATER_SERVICE);
              convertView = inf.inflate(R.layout.parent_layout, null);
          }
          TextView tv = (TextView) convertView.findViewById(R.id.parent_txt);
          ImageView imageView = (ImageView)convertView.findViewById(R.id.parent_img);
          imageView.setImageResource(R.drawable.geofence1);
  
          tv.setText(parent1.getParentName());
         // new DownloadImageTask(imageView).execute(parent1.getParentImage().toString());
          imageLoader.DisplayImage(parent1.getParentImage().toString(), imageView);
          return convertView;
      }
  
  
      @Override
      public boolean hasStableIds() {
          return false;
      }
  
      @Override
      public boolean isChildSelectable(int parentPosition, int childPosition) {
          return true;
      }
  
  
      public Object getGroupName(int parentPosition) {
          Parent parent1 = (Parent) getGroup(parentPosition);
          String parentName = parent1.getParentName();
  
          return parentName;
      }
  
      public Object getChildName(int parentPosition, int childPosition) {
  
          Child child = (Child) getChild(parentPosition, childPosition);
          String childName = child.getName();
  
          return childName;
      }
  
  
  
  
      private class DownloadImageTask extends AsyncTask&lt;String, Void, Bitmap&gt; {
          ImageView bmImage;
  
          public DownloadImageTask(ImageView bmImage) {
              this.bmImage = bmImage;
          }
  
          protected Bitmap doInBackground(String... urls) {
              String urldisplay = urls[0];
              Bitmap mIcon11 = null;
              try {
                  InputStream in = new java.net.URL(urldisplay).openStream();
                  mIcon11 = BitmapFactory.decodeStream(in);
              } catch (Exception e) {
                  Log.e("Error", e.getMessage());
                  e.printStackTrace();
              }
              return mIcon11;
          }
  
          protected void onPostExecute(Bitmap result) {
              bmImage.setImageBitmap(result);
          }
  
      }
  
  
  }   
  </code></pre>
  
  <p>Thanks in advance.</p>