私が直面している問題は、子ImageView
内のリソースを変更しているときです。ExpandableListView
別の親に別の子を設定してから、親子のいずれかの内部でボタンのクリックを次のように処理しています (ここでは、これをすべて で行っています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;
}
}
私を助けてください。