问题
We have an app that's been working for years. So it does NOT use all the latest and greatest features.
We've found that on current versions of Android, IF there is text in an EditText control AND you long-touch it - the app crashes with:
11-13 14:26:20.720: E/AndroidRuntime(1253): FATAL EXCEPTION: main
11-13 14:26:20.720: E/AndroidRuntime(1253): java.lang.IllegalStateException: ActionBarContextView can only be used with android:layout_width="match_parent" (or fill_parent)
11-13 14:26:20.720: E/AndroidRuntime(1253): at com.android.internal.widget.ActionBarContextView.onMeasure(ActionBarContextView.java:325)
11-13 14:26:20.720: E/AndroidRuntime(1253): at android.view.View.measure(View.java:12603)
11-13 14:26:20.720: E/AndroidRuntime(1253): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4677)
11-13 14:26:20.720: E/AndroidRuntime(1253): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1369)
11-13 14:26:20.720: E/AndroidRuntime(1253): at android.widget.LinearLayout.measureVertical(LinearLayout.java:660)
I know that we have no references to an ActionBarContextView anywhere in our xml or java files, nor do we use any Themes. These EditText controls are in Activities, not Dialogs.
We do have a Custom layout as our root layout, and the crash stacktrace does eventually get back to one if it's methods:
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
measureChild(child, widthMeasureSpec, heightMeasureSpec);
}
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(heightMeasureSpec));
}
Any ideas where to look, or what to change?
来源:https://stackoverflow.com/questions/19966250/how-to-avoid-a-illegalstateexception-actionbarcontextview-in-older-app