Reputation: 2202
I'm trying to get my first Android plugin to work. I've successfully registered it and able to execute it. Inside of my plugin execute action, I am trying to do the following:
ctx.setContentView(R.layout.map);
Which contains a new layout to load google maps; however, when I run this I receive the following error:
Only the original thread that created a view hierarchy can touch its views.
Any idea how I should go about doing this?
Upvotes: 3
Views: 1063
Reputation: 29131
You have to run it on UI thread. You can touch UI elements only on UI thread.
runOnUiThread(runb);
private Runnable runb = new Runnable() {
public void run(){
//call setContentView code here.
}
}
Upvotes: 2