Fatal crash: Focus search returned a view that wasn't able to take focus

后端 未结 6 1953
一向
一向 2020-12-11 00:03

My application keeps crashing when I type something in a EditText, but this does not happen always only in some cases. I am running my app on a Samsung Galaxy Tab 2 10.1 WiF

6条回答
  •  长情又很酷
    2020-12-11 01:05

    I have another solution, to trace TextView source codes and match the error log you provided

    TextView.java :

    if (!hasOnClickListeners()) {
        View v = focusSearch(FOCUS_DOWN);
    
        if (v != null) {
            if (!v.requestFocus(FOCUS_DOWN)) {
                throw new IllegalStateException(
                        "focus search returned a view " +
                        "that wasn't able to take focus!");
            }
        }
    }
    

    As a result, I think you could give View.OnClickListener to avoid the error happened.

    ex: textView.setOnClickListener(new OnClickListener);

提交回复
热议问题