【发布时间】:2014-11-08 10:56:22
【问题描述】:
您好所有安卓开发者
我尝试在单击下载按钮时执行内容下载,然后更新该行的 Textview 以显示下载状态
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);
}
我在数据对象中保持目标文本视图的引用并在 Asynctask 中更改文本,但我不知道为什么文本没有更改没人能帮忙? 坦克
【问题讨论】:
-
你的 textview 更新代码?
-
发布你的异步代码
-
@AvinashKumarPankaj 我发布它
-
那么ModelDownload是downloadmanager吗?您是否将 ModelDownload 作为嵌套类(在 OnlineStoreAdapter 中)?
-
@BlazeTama 是 modelDownload 是 asyntask 对象但不是嵌套类
标签: android android-listview android-asynctask