相关疑难解决方法(0)

如何将OnPostExecute()的结果导入主活动,因为AsyncTask是一个单独的类?

我有这两节课.我的主要活动和扩展的一个AsyncTask,现在在我的主要活动,我需要从得到的结果OnPostExecute()AsyncTask.我怎样才能将结果传递给我的主要活动?

这是示例代码.

我的主要活动.

public class MainActivity extends Activity{

    AasyncTask asyncTask = new AasyncTask();

    @Override
    public void onCreate(Bundle aBundle) {
        super.onCreate(aBundle);            

        //Calling the AsyncTask class to start to execute.  
        asyncTask.execute(a.targetServer); 

        //Creating a TextView.
        TextView displayUI = asyncTask.dataDisplay;
        displayUI = new TextView(this);
        this.setContentView(tTextView); 
    }

}
Run Code Online (Sandbox Code Playgroud)

这是AsyncTask类

public class AasyncTask extends AsyncTask<String, Void, String> {

TextView dataDisplay; //store the data  
String soapAction = "http://sample.com"; //SOAPAction header line. 
String targetServer = "https://sampletargeturl.com"; //Target Server.

//SOAP Request.
String soapRequest …
Run Code Online (Sandbox Code Playgroud)

android android-asynctask

338
推荐指数
7
解决办法
27万
查看次数

android asynctask向ui发送回调

我有以下asynctask类,它不在活动中.在我正在初始化asynctask的活动中,我希望asynctask将回调报告回我的活动.可能吗?或者asynctask是否必须与活动位于同一个类文件中?

protected void onProgressUpdate(Integer... values) 
{
    super.onProgressUpdate(values);
    caller.sometextfield.setText("bla");
}
Run Code Online (Sandbox Code Playgroud)

像这样的东西?

android android-asynctask

146
推荐指数
3
解决办法
13万
查看次数

如何在android中创建自己的Listener接口?

有人可以帮助我用一些代码片段创建用户定义的监听器界面吗?

android

125
推荐指数
6
解决办法
19万
查看次数

标签 统计

android ×3

android-asynctask ×2