fix RuntimeException when inflating default layout for AdapterView-based widgets

Bug: 151901506
Test: manual
Change-Id: I71068b7d13783f658c02cc76ec50f40319e68160
This commit is contained in:
Pinyao Ting
2020-05-18 16:49:02 -07:00
parent a611e762ad
commit 5cb48cbc0d

View File

@@ -625,7 +625,10 @@ public class AppWidgetHostView extends FrameLayout {
}
}
defaultView = inflater.inflate(layoutId, this, false);
defaultView.setOnClickListener(this::onDefaultViewClicked);
if (!(defaultView instanceof AdapterView)) {
// AdapterView does not support onClickListener
defaultView.setOnClickListener(this::onDefaultViewClicked);
}
} else {
Log.w(TAG, "can't inflate defaultView because mInfo is missing");
}