android TextView setText not working

前端 未结 7 2008
被撕碎了的回忆
被撕碎了的回忆 2021-01-04 02:37

I know there are a lot of similar threads but I\'ve gone through them and still can\'t figure out the problem. My program reaches the Handler but it always returns the catc

相关标签:
7条回答
  • 2021-01-04 03:03

    For future reference, I had multiple fragments, one for each tab in my ViewPager. One TextView had the same id in two fragments and that created a conflict. I didn't realize I had the same id so everything seemed fine, no error message, but the text simply didn't change. Therefore I'd recommend using unique names for the id.

    0 讨论(0)
  • 2021-01-04 03:03

    In my case, I found there are a TextWatcher and a Filter linked to my Textview, which both contain a logic that prevents the updating of my Textview value.
    So additionally to other solutions, you can check if your Textview is linked to any TextWatcher or Filter and then trace it.

    0 讨论(0)
  • 2021-01-04 03:08

    You haven't given us much to go on.

    You should look at the exception stack trace, instead of printing a message to the console: e.printStackTrace();

    But from here, if I had to guess, it looks like you're either setting the TextView's text off the main thread, or - and which appears unlikely based on what you've posted - your TextView has not been set and you have a null pointer exception.

    0 讨论(0)
  • 2021-01-04 03:11

    just like this is ok!

    private void setUpViews() {
        chatbox = (TextView) findViewById(R.id.chatbox);
        chatbox.setText("Got it!");
    }
    
    0 讨论(0)
  • 2021-01-04 03:12

    when the textColor is the same as View's background color ,the text also sees invisible ,so you can define a textColor to solve it

    0 讨论(0)
  • 2021-01-04 03:12

    have you send a message? for example:

                Message message=new Message();
            message.what=1;
            mHandler.sendMessage(message);
    
    0 讨论(0)
提交回复
热议问题