2014-11-08 92 views
-2

大家好Android开发者
我尝试执行的内容下载时,点击下载按钮,然后为了显示下载的状态更新该行的TextView的的Android更新的TextView从的AsyncTask

public OnlineStoreAdapter extends 
    ArrayAdapter<MusicDownloadStructure>{ 
    public View getView(int position, View view, ViewGroup parent) { 
     // TODO Auto-generated method stub 
     final MusicDownloadStructure data = ModelDownloadData[position]; 
     . 
     . 
     Downloadbtn.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      downloadmanager = new ModelDownload(URL, data); 
      downloadmanager.execute(); 
     } 
    } 
} 

public class ModelDownload extends AsyncTask<Object, Long, Boolean> { 

    public ModelDownload(String URL, MusicDownloadStructure downloadStructure) { 
     connectionurl = URL; 
     DownloadStructure = downloadStructure; 
    } 
    protected void onPostExecute(Boolean result) { 
     // TODO Auto-generated method stub 
     TextView statusTextView = DownloadStructure.getStatusTextView(); 
     statusTextView.setText(TitleStirng); 
    } 

我保持数据对象中的目标文本视图的Refrence和更改Asynctask中的文本,但我不知道为什么文本没有改变没有人可以帮助? 坦克

+0

乌尔更新TextView的代码? – 2014-11-08 10:59:24

+0

发布您的异步代码 – 2014-11-08 10:59:27

+0

@AvinashKumarPankaj我发布了 – FxRi4 2014-11-08 11:06:03

回答

1

尝试调用notifyDataSetChanged

 protected void onPostExecute(Boolean result) { 
      ... 
      myListView.notifyDataSetChanged(); //or simply notifyDataSetChanged if your Async inside adapter 
     }