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

后端 未结 6 1952
一向
一向 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 00:44

    I was having this same crash and although it doesn't sound like the exact situation, perhaps this will still be helpful:

    I had two EditText boxes. The bottom one was the Next Focus Down of the top one. In some situations I would hide the bottom box, so when I hit next on the keyboard from the top box, it would try to go the bottom one, but would crash since it was hidden. I fixed this by setting the bottom box (the target of another EditText's Next Down Focus) as not focusable:

        EditText inputBox = (EditText)findViewById(R.id.Bottom_Box);
        inputBox.setFocusable(false);
    

    I hope this helps.

提交回复
热议问题