Button Click Handling inside the ExpandableListView Child

187
January 16, 2018, at 9:07 PM

A problem that I am facing which is, When I am changing the ImageView Resource inside the ExpandableListView child. I am setting different Child for Different parent and then I am handling the button click inside one of the parent-child as (Here I am doing all this in groupPosition ==3):

FilterAdapter.java

public  class FilterAdapter extends BaseExpandableListAdapter {
    List<String> groupList;
    Map<String,List<String>> childMapList;
    List<String> childList;
    Context mContext;
    FilterListGroupLayoutBinding binding;
    FilterbyChildLayoutBinding filterbyChildLayoutBinding;
    TransferStatusChildLayoutBinding transferStatusChildLayoutBinding;
    SortByDateChildLayoutBinding sortByDateChildLayoutBinding;
    private static String  childView= "";
    private static String groupName="";
    private static String childName="";
    static  int c=1;
    TextView ivPickUpTxt;
    ImageButton pickUpImage,vouchredImage,cancledImage;
    ImageSwitcher bookedonImage;
    CheckBox pendingyesCheckBox,pendingNoCheckBox,vehicleAssignCheckBox,vehicleAssignNoCheckbox,driverYesCheckBox,driverNoCheckbox,vehicleDispatchCheckBox;
   CheckBox vehicleDispatchNocheckbox,transferCompletedYesCheckBox,transferCompletedNoCheckBox;
    CheckBox  ivCancleCheckBox,voucheredCheckBox;
    RelativeLayout text2Layout,text1Layout;
    View convertView1;
    TextView bookedonToTxt,bookedOnEdtTxt, pickUpFromEditTxt,pickupDateToText;
    EditText supplierConfNo,confEditTxt,passangerNameTxt,pickUpEditTxt ;
    Button btm,btm1;
    String dateTime;
//    FilterFragment filterFragment = new FilterFragment();
    SimpleDateFormat sdf =  new SimpleDateFormat("dd-MM-yyyy");
    public FilterAdapter(Context context, List<String> groupList, Map<String,List<String>> childMapList) {
        this.groupList=groupList;
        this.childMapList = childMapList;
        this.mContext = context;
    }
    @Override
    public int getGroupCount() {
        return groupList.size();
    }
    @Override
    public int getChildrenCount(int groupPosition) {
        return 1;
    }
    @Override
    public Object getGroup(int groupPosition) {
        return groupList.get(groupPosition);
    }
    @Override
    public Object getChild(int groupPosition, int childPosition) {
        String s;
        s = groupList.get(groupPosition);
        childList = childMapList.get(s);
        return childList.get(childPosition);
    }
    @Override
    public long getGroupId(int groupPosition ) {
        return groupPosition;
    }
    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }
    @Override
    public boolean hasStableIds() {
        return false;
    }
    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View view, ViewGroup viewGroup) {
        String headerTitle = (String) getGroup(groupPosition);
        if(view == null){
            LayoutInflater infalInflater = (LayoutInflater) this.mContext
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = infalInflater.inflate(R.layout.filter_list_group_layout, null);
            /*binding = DataBindingUtil.inflate(LayoutInflater.from(viewGroup.getContext()), R.layout.filter_list_group_layout,viewGroup,false);
            view = binding.getRoot()*/;
        }
        ImageView groupIndicatorImage = (ImageView) view.findViewById(R.id.groupIndicatorImage);
        ExpandableListView eLV = (ExpandableListView) viewGroup;
       eLV.expandGroup(0);

        if (isExpanded) {
            if(groupPosition==0){
                groupIndicatorImage.setVisibility(View.INVISIBLE);
            }else {
                groupIndicatorImage.setVisibility(View.VISIBLE);
                groupIndicatorImage.setBackgroundResource(R.drawable.arrow_down);
            }
        } else if (!isExpanded) {
            if(groupPosition==0){
                groupIndicatorImage.setVisibility(View.INVISIBLE);
            }else {
                groupIndicatorImage.setVisibility(View.VISIBLE);
                groupIndicatorImage.setBackgroundResource(R.drawable.filter_arrow);
            }
        }
        TextView groupIndicator = (TextView) view.findViewById(R.id.ivGroupIndicator);
        groupIndicator.setText(headerTitle);
       /* binding.ivGroupIndicator.setText(headerTitle);*/
        return view;
    }
    @Override
    public void onGroupCollapsed(int groupPosition) {
        super.onGroupCollapsed(groupPosition);
    }
    @Override
    public View getChildView(int groupPosition, int childPosition, boolean b, View convertView, ViewGroup viewGroup) {
        LayoutInflater infalInflater = (LayoutInflater) this.mContext
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        String headerTitle = (String) getGroup(groupPosition);
        int childType = getChildType(groupPosition, childPosition);
//        String child = getChild(groupPosition, childPosition).toString();
        String parent = ((String) getGroup(groupPosition));
// || (int)convertView.getTag()!= childType
        if(convertView == null){
            if(groupPosition == 0){
                convertView = infalInflater.inflate(R.layout.booking_status_child_layout, null);
            }
            else if(groupPosition == 1){
                convertView = infalInflater.inflate(R.layout.filterby_child_layout, null);
            }
            else if(groupPosition == 2){
                convertView = infalInflater.inflate(R.layout.transfer_status_child_layout, null);
            }
            else if(groupPosition == 3){
                convertView = infalInflater.inflate(R.layout.sort_by_date_child_layout, null);
            }
        }
        else{
            if(groupPosition == 0){
                convertView = infalInflater.inflate(R.layout.booking_status_child_layout, null);

            }
           else if(groupPosition == 1){
                convertView = infalInflater.inflate(R.layout.filterby_child_layout, null);

            }
            else if(groupPosition == 2){
                convertView = infalInflater.inflate(R.layout.transfer_status_child_layout, null);

            }
            else if(groupPosition == 3){

                convertView = infalInflater.inflate(R.layout.sort_by_date_child_layout, null);
                /*image.... initialization*/
                bookedonImage = (ImageSwitcher) convertView.findViewById(R.id.booedOnImage);
                btm = (Button) convertView.findViewById(R.id.btm);
                btm1 = (Button) convertView.findViewById(R.id.btm1);

                bookedonImage.setFactory(new ViewSwitcher.ViewFactory() {
                    @Override
                    public View makeView() {
                        ImageView myView = new ImageView(mContext);
                        myView.setScaleType(ImageView.ScaleType.FIT_CENTER);
                        return myView;
                    }
                });
                btm.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                            bookedonImage.setImageResource(R.drawable.ascending_active);
                    }
                });
                btm1.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                            bookedonImage.setImageResource(R.drawable.decending_active);
                    }
                });

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

Please help me out.

READ ALSO
how to fix unsupported type &#39;group&#39; in android studio??? if anybody help i&#39;ll appreciate it? [on hold]

how to fix unsupported type 'group' in android studio??? if anybody help i'll appreciate it? [on hold]

This is the activity main drawerxml file and whenever i tied to run the program it is giving me

223
How to detect a Removable External USB and its custom file types within through Storage Access Framework?

How to detect a Removable External USB and its custom file types within through Storage Access Framework?

We have a custom android device that is running Nougat and is wrapped in a vendor specific launcherI am trying to implement a File Manager for the said device with the use of API 23

193
Saving a list of classes

Saving a list of classes

So I have a pretty big chain of classes inside each other, one class which has all the values and the other classes in it, they're all saved in a list like thisAnother thing to keep in mind, each value has about 5 classes inside and there are about 3-4 values...

196
Buildfire: Is it possible to pass a parameters upon downloading and opening the app from the Play Store

Buildfire: Is it possible to pass a parameters upon downloading and opening the app from the Play Store

I have a situation where I sent an email to a user which contains the link of the app to the Play Store, which will then need to pass some parameters to the link upon downloading the app in the Play store, so the user will no longer have to input the data from the parameters...

159