В моем приложении я использую мыльный вызов webservice, основываясь на ответе на вызов webservice, мне нужно отобразить некоторые сообщения.,
Но после ответа я не смог сделать это из порожденной дочерней нити
Итак, как вернуться к основной теме и отобразить это после того ответа, который я получил
Надеюсь, это понятно .. помогите мне, как выполнить мое требование
{
Thread t1 = new Thread() {
public void run() {
String threadName = Thread.currentThread().getName();
// There will be delay in this statement while fetching a data from webservice
String returnfromWebservice = webservice(xmlDetails, "generateid");
Log.v("returnfromWebservice",returnfromWebservice);
if( ! returnfromWebservice.equalsIgnoreCase("nil")){
gotid = returnfromWebservice;
gotReply=true;
// dothis();// I could able to do this because this method contains widgets
// I am gettin the error : Only the original thread that created a view hierarchy can touch its views.
//I understand this is because childthread has no controls on widget
/**Suggest me how to get back to main thread*/
}
}};
t1.start();
dothis();// so i am doin here after the completion of it
}
public void dothis{
if(gotReply){
idtext.setText(gotid);
genId.setEnabled(false);
Toast.makeText(WelcomeScorer.this, "Generated ", 500).show();
}
else{
Toast.makeText(WelcomeScorer.this, "Try Once More ", 500).show();
idtext.setText(gotid);
}
}
Я новичок в Android, есть ли лучший подход в Android API, чтобы справиться с этой ситуацией ??