简体   繁体   中英

Android ExpandableListview

Any tutorial for ExpandableListview For android with Fold animation ? I m using this adapter but it's not smooth i don't know why , any suggestions for a smooth adapter and how i can include Fold animation while collapse and expand

My adapter is :

public class Customlistadapter extends BaseExpandableListAdapter {

List<CategoriesObject> categoriesObjectList;

Context context;

ImageView rightimage;
ImageView iconImage;
public LayoutInflater inflater;
public serviceHelper serviceHandler;
ImageLoader imgloader;

public Customlistadapter(Activity context, List<CategoriesObject> categoriesObjectList) {
    // super(context, R.layout.list_content_row);
    // TODO Auto-generated constructor stub
    this.categoriesObjectList = categoriesObjectList;
    this.context = context;
    inflater = context.getLayoutInflater();
    imgloader = new ImageLoader(context);
}

@Override
public ServiceObject getChild(int groupPosition, int childPosition) {
    List<ServiceObject> chList = categoriesObjectList.get(groupPosition).services;
    return chList.get(childPosition);
}

@Override
public long getChildId(int groupPosition, int childPosition) {
    return childPosition;
}

@Override
public View getChildView(int groupPosition, int childPosition,
                         boolean isLastChild, View convertView, ViewGroup parent) {

    ServiceObject child = (ServiceObject) getChild(groupPosition, childPosition);
    if (convertView == null) {
        LayoutInflater infalInflater = (LayoutInflater) context
                .getSystemService(context.LAYOUT_INFLATER_SERVICE);
        convertView = infalInflater.inflate(R.layout.servicelist_content_row, null);
    }

    ServicesManager.setContext(this.context);
    if(ServicesManager.serviceIsSelected(child))
    {
        convertView.findViewById(R.id.menutitle).setBackgroundColor(Color.parseColor("#CC0fcb9e"));
        RotateAnimation anim = new RotateAnimation(0f,45f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
                0.5f);
        // Step 2:  Set the Animation properties

        anim.setRepeatCount(0);
        anim.setInterpolator(new LinearInterpolator());
        anim.setDuration(1200);
        anim.setFillAfter(true);

        // Step 3: Start animating the image
        ImageView leftimage  = (ImageView)convertView.findViewById(R.id.leftimage);
        leftimage.startAnimation(anim);
    }
    else
    {
        convertView.findViewById(R.id.menutitle).setBackgroundColor(Color.parseColor("#CC0fcb9e"));
        RotateAnimation anim = new RotateAnimation(45f, 0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
                0.5f);
        // Step 2:  Set the Animation properties

        anim.setRepeatCount(0);
        anim.setInterpolator(new LinearInterpolator());
        anim.setDuration(1200);
        anim.setFillAfter(true);

        // Step 3: Start animating the image
        ImageView leftimage  = (ImageView)convertView.findViewById(R.id.leftimage);
        leftimage.startAnimation(anim);
        convertView.findViewById(R.id.menutitle).setBackgroundColor(Color.parseColor("#CC2e5c78"));
    }



    final TextView tv = (TextView) convertView.findViewById(R.id.title);

    TextView price = (TextView) convertView.findViewById(R.id.priceTxt);
    tv.setText(child.servicename.toString());
    price.setText(String.valueOf(child.serviceprice));

    return convertView;
}

@Override
public int getChildrenCount(int groupPosition) {
    List<ServiceObject> chList = categoriesObjectList.get(groupPosition).services;
    return chList.size();
}

@Override
public CategoriesObject getGroup(int groupPosition) {
    return categoriesObjectList.get(groupPosition);
}

@Override
public int getGroupCount() {
    return categoriesObjectList.size();
}

@Override
public long getGroupId(int groupPosition) {
    return groupPosition;
}

@Override
public View getGroupView(int groupPosition, boolean isExpanded,
                         View convertView, ViewGroup parent) {
    CategoriesObject group = (CategoriesObject) getGroup(groupPosition);
    if (convertView == null) {
        LayoutInflater inf = (LayoutInflater) context
                .getSystemService(context.LAYOUT_INFLATER_SERVICE);
        convertView = inf.inflate(R.layout.list_content_row, null);
    }
    TextView tv = (TextView) convertView.findViewById(R.id.title);
    ImageView iconImage = (ImageView)convertView.findViewById(R.id.iconImage);



    imgloader.DisplayImage(group.catimage,iconImage);
  //  new ImageLoadTask(group.catimage, iconImage).execute();

    tv.setText(group.catname);
    return convertView;
}

@Override
public boolean hasStableIds() {
    return true;
}

@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
    return true;
}


private static class ChildHolder {
    TextView title;
    TextView hint;
}

public interface serviceHelper {
    public void serviceClicked(int grouppos, int childpos);
}

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM