public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
((DownloadFragment) downloads).refreshlist();
}
}
public class MyAdapter extends ArrayAdapter<AdapterItem> {
public MyAdapter(Context context, int textviewid) {
super(context, textviewid); // NPE here
}
public void refreshlist() {
items.clear();
adapter = new MyAdapter(getActivity(), 0);
// ...
}
}
java.lang.NullPointerException
at android.widget.ArrayAdapter.init(ArrayAdapter.java:310)
at android.widget.ArrayAdapter.<init>(ArrayAdapter.java:104)
at com.DownloadFragment$MyAdapter.<init>(DownloadFragment.java:142)
at com.DownloadFragment.refreshlist(DownloadFragment.java:479)
at com.MainActivity.onWindowFocusChanged(MainActivity.java:387)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onWindowFocusChanged(PhoneWindow.java:2466)
at android.view.View.dispatchWindowFocusChanged(View.java:7456)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:935)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3264)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5297)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
downloadfragment.java
Cursor a = mDbHelper.getEachDownload(2);
我相信这是因为您传递了一个空上下文。
尝试:
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
((DownloadFragment) downloads).refreshlist(this);
}
}
downloadfragment.java
public class MyAdapter extends ArrayAdapter<AdapterItem> {
public MyAdapter(Context context, int textviewid) {
super(context, textviewid); // NPE here
}
public void refreshlist(Context context) {
items.clear();
adapter = new MyAdapter(context, 0);
// ...
}
}
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
DownloadFragment.adapter.notifyDataSetChanged();
}
}
import "context" Package context defines the Context type, which carries deadlines,cancelation signals, and other request-scoped values across API boundaries and between processes. Incoming requests t
ConTEXT 是一个小型、快速而且功能强大的文本编辑器,可作为程序员的附件工具,支持多种语言的语法着色。
前面不止一次讲过, Python 中子类会继承父类所有的类属性和类方法。严格来说,类的构造方法其实就是实例方法,因此毫无疑问,父类的构造方法,子类同样会继承。 但我们知道,Python 是一门支持多继承的面向对象编程语言,如果子类继承的多个父类中包含同名的类实例方法,则子类对象在调用该方法时,会优先选择排在最前面的父类中的实例方法。显然,构造方法也是如此。 举个例子: 运行结果,结果为: 我是人,
super-diamond 提供系统参数配置管理,例如数据库的配置信息等,配置参数修改以后可以实时推送到客户端(基于netty4), 方便系统动态修改运行参数。 可以建多个项目,每个项目分为三种profile(development、test、production), 能够控制profile 级别的权限。 所有参数均由development profile配置,test和production pr
super-bbs 是一个基于Flask的bbs论坛类项目,前端由Vue 开发,有用户和管理员两套界面。 声明: 严重高仿(照抄)V2EX 开发原因: 前后端分离,替换原来的 FakeV2EX 项目
Super Rentals This is a working repository for the Super Rentals tutorial,which you can check out at https://guides.emberjs.com/release/tutorial/. Prerequisites You will need the following things prop