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

前端 未结 8 2038
孤城傲影
孤城傲影 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");
    }
    

提交回复
热议问题