Android, java - Unable to update variable from asynctask

后端 未结 4 1006
别那么骄傲
别那么骄傲 2021-02-11 04:39

Here is the code

Variable declared

 public String gpu2dcurent = \"1234567\";

Asynctask, after finished it should update variable gpu2dc

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-11 05:31

    try to put setText into onPostExecute

    protected void onPostExecute(String result) {
         TextView tx = (TextView)findViewById(R.id.textView3);
         tx.setText(result);
    
         // Pass the result data back to the main activity
        gpu2dcurent = result;
         //Toast.makeText(getBaseContext(), result,
         //Toast.LENGTH_SHORT).show();
         gpu.this.data = result;
    
         if (gpu.this.pd != null) {
             //gpu.this.pd.dismiss();
         }
     }
    

提交回复
热议问题