Why can't I set text to an Android TextView?

前端 未结 8 2028
孤城傲影
孤城傲影 2020-12-31 03:04

I\'m having a problem with setting text to a TextView:

TextView android:editable = \"true\".

In my .java it seems like that this should wor

相关标签:
8条回答
  • 2020-12-31 03:47

    I was having a similar problem, however my program would crash when I tried to set the text. I was attempting to set the text value from within a class that extends AsyncTask, and that was what was causing the problem.

    To resolve it, I moved my setText to the onPostExecute method

    protected void onPostExecute(Void result) {
        super.onPostExecute(result);
    
        TextView text = (TextView) findViewById(R.id.errorsToday);
        text.setText("new string value");
    }
    
    0 讨论(0)
  • 2020-12-31 03:49

    To settext in any of in activity than use this below code... Follow these step one by one:

    1.Declare

        private TextView event_post;
    

    2.Bind this

        event_post = (TextView) findViewById(R.id.text_post);
    

    3.SetText in

        event_post.setText(event_post_count);
    
    0 讨论(0)
提交回复
热议问题