图片选择器的问题
来源:4-15 图片选择器功能实现-4
慕粉3818146
2020-09-01
我这边创建了图片选择器,过后再调用的时候出现了这个问题
这是我调用的代码:
@Override
protected void initData() {
super.initData();
mGalley.setUp(getLoaderManager(), new GalleyView.SelectedChangeListener() {
@Override
public void onSelectedCountChanged(int count) {
}
});
}
这是报错的代码:
2020-09-01 15:58:07.215 7373-7373/com.hl.muliao E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.hl.muliao, PID: 7373
java.lang.NullPointerException: Attempt to invoke virtual method 'int com.hl.common.widget.GalleyView.setUp(androidx.loader.app.LoaderManager, com.hl.common.widget.GalleyView$SelectedChangeListener)' on a null object reference
at com.hl.muliao.fragment.main.ActiveFragment.initData(ActiveFragment.java:27)
at com.hl.common.app.Fragment.onViewCreated(Fragment.java:58)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:892)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2663)
at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:246)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:542)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:210)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1425)
at android.app.Activity.performStart(Activity.java:7825)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3294)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
2020-09-01 15:58:12.954 1836-7412/? E/ResolverController: No valid NAT64 prefix (100, <unspecified>/0)
老师有空的时候帮我看下,我这边的android studo 版本是 4.0.1
这是GalleyView.java 引用的相关代码
import android.database.Cursor;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.CursorLoader;
写回答
2回答
-
慕粉3818146
提问者
2020-09-02
我看你的视频里面首页有很多图片,我这边没有图片是这个原因吗?你这些图片数据是再哪儿添加的,还是相册里面自带的图片哦
012020-09-03 -
Qiujuer
2020-09-02
common.widget.GalleyView.setUp(androidx.loader.app.LoaderManager, com.hl.common.widget.GalleyView$SelectedChangeListener)' on a null object reference
证明:GalleyView为null,
应该是没有绑定好View,导致在初始化的时候View的实例为null。也就是你的注入绑定没绑定好。
00
相似问题
图片选择器
回答 3
图片选择器布局View大小问题
回答 1