が、私はいくつかのメッセージを表示する必要があるWebサービス呼び出しの応答に基づいて、石鹸のWebサービス呼び出しを使用していた子スレッドからは、。私のアプリで
をメインTHEADのメソッドを呼び出すことではなく、返信後、私はできませんでしたメインスレッドに戻って取得し、これが明確である
希望を持って、私の返信後にこれを表示する。..私の要件を達成するためにどのように私を助けるためにどのように
だから、生まれた子スレッドからこれを行うことができる
{
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);
}
}
私はアンドロイドに新しいです、この状況を処理するためのアンドロイドAPIの中で最善のアプローチはありますか?