我尝试使用onFocusChangeListener制作三个可以点击的EditTexts,但有时我会得到这个:
03-02 11:57:06.340: E/InputEventReceiver(24904): Exception dispatching input event.
03-02 11:57:06.342: E/MessageQueue-JNI(24904): Exception in MessageQueue callback: handleReceiveCallback
03-02 11:57:08.142: E/MessageQueue-JNI(24904): java.lang.StackOverflowError: stack size 8MB
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.text.Layout.primaryIsTrailingPrevious(Layout.java:742)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.text.Layout.getPrimaryHorizontal(Layout.java:805)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.text.Layout.getPrimaryHorizontal(Layout.java:796)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.widget.TextView.getFocusedRect(TextView.java:5452)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.FocusFinder.findNextFocusInAbsoluteDirection(FocusFinder.java:232)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.FocusFinder.findNextFocus(FocusFinder.java:163)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.FocusFinder.findNextFocus(FocusFinder.java:94)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.FocusFinder.findNextFocus(FocusFinder.java:65)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.widget.ScrollView.onRequestFocusInDescendants(ScrollView.java:1454)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.requestFocus(ViewGroup.java:2622)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2663)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.requestFocus(ViewGroup.java:2619)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2663)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.requestFocus(ViewGroup.java:2619)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2663)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.requestFocus(ViewGroup.java:2619)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2663)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.requestFocus(ViewGroup.java:2619)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2663)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.requestFocus(ViewGroup.java:2622)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.requestFocus(View.java:7594)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.requestFocus(View.java:7573)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.rootViewRequestFocus(View.java:5082)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.clearFocusInternal(View.java:5068)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.clearFocus(View.java:5045)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at com.example.stoos.NeuesSpiel$5.onFocusChange(NeuesSpiel.java:238)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.onFocusChanged(View.java:5182)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.widget.TextView.onFocusChanged(TextView.java:7897)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.handleFocusGainInternal(View.java:4938)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.requestFocusNoSearch(View.java:7648)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.requestFocus(View.java:7627)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.widget.ScrollView.onRequestFocusInDescendants(ScrollView.java:1467)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.requestFocus(ViewGroup.java:2622)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2663)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.requestFocus(ViewGroup.java:2619)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2663)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.requestFocus(ViewGroup.java:2619)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2663)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.requestFocus(ViewGroup.java:2619)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2663)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.requestFocus(ViewGroup.java:2619)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2663)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.requestFocus(ViewGroup.java:2622)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.requestFocus(View.java:7594)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.requestFocus(View.java:7573)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.rootViewRequestFocus(View.java:5082)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.clearFocusInternal(View.java:5068)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.clearFocus(View.java:5045)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at com.example.stoos.NeuesSpiel$5.onFocusChange(NeuesSpiel.java:238)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.onFocusChanged(View.java:5182)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.widget.TextView.onFocusChanged(TextView.java:7897)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.handleFocusGainInternal(View.java:4938)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.requestFocusNoSearch(View.java:7648)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.View.requestFocus(View.java:7627)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.widget.ScrollView.onRequestFocusInDescendants(ScrollView.java:1467)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.requestFocus(ViewGroup.java:2622)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2663)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.requestFocus(ViewGroup.java:2619)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2663)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.requestFocus(ViewGroup.java:2619)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2663)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.requestFocus(ViewGroup.java:2619)
03-02 11:57:08.142: E/MessageQueue-JNI(24904): at android.view.ViewGroup.
03-02 11:57:08.782: E/AndroidRuntime(24904): FATAL EXCEPTION: main
03-02 11:57:08.782: E/AndroidRuntime(24904): Process: com.example.stoos, PID: 24904
03-02 11:57:08.782: E/AndroidRuntime(24904): java.lang.StackOverflowError: stack size 8MB
我使用此代码:
buttonEditText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus){
v.clearFocus();
Intent i = new Intent(getApplicationContext(), LeuteEinladen.class);
startActivityForResult(i, Details);
});
}
}
});
我开始的活动完全正常,所以这不是理由。当我尝试使用普通Button和onClickListener时,没有问题。 我也尝试使用EditText上的onClickListener,但这也不起作用。 现在我解决了,问题总是出现,当我启动Activity(点击EditText)关闭它,所以我回到使用EditTexts的Acitivity并想要点击另一个带有onFocusChangeListener的EditText 为了避免这种情况,我该怎么做?在此先感谢:)
答案 0 :(得分:0)
当您第一次启动时,您的活动会自动调用onfocuschange方法,因为此时它会收到onfocus,您的logcat显示stackoverflow错误,这意味着您的活动没有其他控件来接收onfocus,因此它表示stackoverflow