Android Cannot execute setListAdapter() user thread.
- by Ameya
I got a class
class MyClass extends ListActivity implements Runnable{
ArrayList array;
onCreate(){
Thread thread = new Thread(this);
hread.start();
}
@Overriding
void run(){
addAnElement();
}
void addAnElement(){
if(null==array)
array=new ArrayList();
array.add("Some junck string");
this.setListAdapter(.....,array);
}
}
on executing in emulator get error
ERROR/AndroidRuntime(288): android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
I know we cannot access UI calls from user thread.
Can anyone help.