Search code examples
androidsettext

seting setText failure after onActivityResult


I use ViewPager+Tabhost framework.

I pass startActivityForResult(B activity,100), in a Activity. And pass setResult(200, data); in B.

It can receive the value from B in A:String b = data.getStringExtra("b");

It can also see the value use Log.

But it can not set the value use tv.setText(b); in A. I can not set the value use tv.setText(“dasfasd”); either. I do not the reason.

Why It can not set the value?


Solution

  • Try this :

    Activity_A.this.runOnUiThread(new Runnable() {    
            public void run() {
                tv.setText("dasfasd");    
            }
    });