有一DownloadTask类代码如下
public class DownloadTask extends AsyncTask<String, Integer, Integer> {
................ private Context context;
LayoutInflater factory = LayoutInflater.from(context);
View layout = factory.inflate(R.layout.activity_main, null);
ProgressBar downloadProgress = (ProgressBar) layout.findViewById(R.id.download_progress); public DownloadTask(DownloadListener listener, Context context) {
this.listener = listener;
this.context = context;
}....................
}
在DownloadService中使用
private DownloadTask downloadTask ;
downloadTask = new DownloadTask(listener,DownloadService.this);红色字体为空指针位置大神们帮忙看看吧,万分感谢!!!
public class DownloadTask extends AsyncTask<String, Integer, Integer> {
................ private Context context;
LayoutInflater factory = LayoutInflater.from(context);
View layout = factory.inflate(R.layout.activity_main, null);
ProgressBar downloadProgress = (ProgressBar) layout.findViewById(R.id.download_progress); public DownloadTask(DownloadListener listener, Context context) {
this.listener = listener;
this.context = context;
}....................
}
在DownloadService中使用
private DownloadTask downloadTask ;
downloadTask = new DownloadTask(listener,DownloadService.this);红色字体为空指针位置大神们帮忙看看吧,万分感谢!!!
解决方案 »
- 请问HTC 机器有什么特别之处吗?
- 求一段android平台下的Get网页数据的代码
- 自定义RadioGroup加载的图片如何实现点击切换图片
- 请教关于MediaRecorder!
- 请问下,ANDROID自动化测试如何将手机屏幕模拟到PC机器上,同时可以通过PC机来操作手机?
- 求助【Android】使用哪种布局比较好?
- SimpleExpandableListAdapter 问题
- 求牛人指点ContentResolver.delete()里面参数含义
- Android的BroadcastReceiver在開機觸發時報錯
- 安卓开发,网络请求时闪退!求大佬
- 点击按钮控制gridlayout显示对应的不同内容
- 新手求教,如何解决此处错误
................ private Context context;
LayoutInflater factory = LayoutInflater.from(context);
View layout = factory.inflate(R.layout.activity_main, null);
ProgressBar downloadProgress = (ProgressBar) layout.findViewById(R.id.download_progress); public DownloadTask(DownloadListener listener, Context context) {
this.listener = listener;
this.context = context;
factory = LayoutInflater.from(context);
View layout = factory.inflate(R.layout.activity_main, null);
ProgressBar downloadProgress = (ProgressBar) layout.findViewById(R.id.download_progress); }
....................
}
................ private Context context;
LayoutInflater factory;
View layout ;
ProgressBar downloadProgress; public DownloadTask(DownloadListener listener, Context context) {
this.listener = listener;
this.context = context;
factory = LayoutInflater.from(context);
layout = factory.inflate(R.layout.activity_main, null);
downloadProgress = (ProgressBar) layout.findViewById(R.id.download_progress);
}
....................
}