I have a custom ExpandableListAdapter (that extends BaseExpandableListAdapter), inside of which I am overriding the isChildSelectable
method and returning true
:
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
Inside the overrided onCreateView
method inside my Fragment class I am setting an onChildClickListener
this way:
expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
try {
DownloadThisPatientInfo.downloadThisPatientInfo(...);
return true;
} catch (NullPointerException e) {
return false;
}
}
});
The code inside onChildClick
method is not being called.
First of all: the Logcat shows no errors, and the program just continues its execution after clicking a child, as if I didn't click it. No errors, no warnings, nothing.
I tried setting a breakpoint then going into debugging mode. Breakpoint in line:
try {
This breakpoint isn't being triggered after a child click. Just in case, I tried making a Log.d(str, str) call just before the try
block:
expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
Log.d("TESTING", "### Child Clicked.");
try { ... }
catch ( ... ) { ... }
});
Nothing appears in the Log.
Obviously the code inside onChildClick
isn't being called. I am sure it must be something quite obvious. Why is this happening? I'll update with more code if it's necessary.
答案 0 :(得分:0)
解决。请考虑将android:descendantFocusability="blocksDescendants"
添加到商品的父级LinearLayout。