Android-PickerView 在部分机型上(小米Note 系统版本7.0),包含模拟器(如夜神 4.4版本)报找不到布局

afdcj2ne  于 5个月前  发布在  Android
关注(0)|答案(2)|浏览(64)

android.content.res.Resources$NotFoundException: File res/layout/layout_basepickerview.xml from xml type layout resource ID #0x7f0b00a3
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2356)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2311)
at android.content.res.Resources.getLayout(Resources.java:939)
at android.view.LayoutInflater.inflate(LayoutInflater.java:395)
at com.bigkoo.pickerview.view.BasePickerView.initViews(BasePickerView.java:87)
at com.bigkoo.pickerview.view.OptionsPickerView.initView(OptionsPickerView.java:37)
at com.bigkoo.pickerview.view.OptionsPickerView.(OptionsPickerView.java:32)
at com.bigkoo.pickerview.builder.OptionsPickerBuilder.build(OptionsPickerBuilder.java:248)
at com.tima.code.views.activitys.AbstractAddressAndMapActivity.proPicker(AbstractAddressAndMapActivity.kt:354)
at com.tima.code.views.activitys.AbstractAddressAndMapActivity$onCreate$2.onClick(AbstractAddressAndMapActivity.kt:439)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5019)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Assetmanager has been closed
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:486)
报错位置在 BasePickerView 87行:{ rootView = (ViewGroup) layoutInflater.inflate(R.layout.layout_basepickerview, mPickerOptions.decorView, false);}

使用kotlin 在abstract中:
if (pros.isEmpty()) {
for (dis in it.districts) {
pros.add(dis.name)
}
}
pickerPro = OptionsPickerBuilder(context, object : OnOptionsSelectListener {
override fun onOptionsSelect(options1: Int, options2: Int, options3: Int, v: View?) {

}
        })
                .setTitleText("选择省")
                .isRestoreItem(true)//切换时是否还原,设置默认选中第一项。
                .isCenterLabel(false) //是否只显示中间选中项的label文字,false则每项item全部都带有label。
                .setOptionsSelectChangeListener(object : OnOptionsSelectChangeListener {
                    override fun onOptionsSelectChanged(options1: Int, options2: Int, options3: Int) {
                        LogUtils.i("RegisterPrivateActivity2", options1.toString() + "," +
                                "" + options2 + "," + options3)
                    }

                })
                .build()
        pickerPro?.setPicker(pros)
        pickerPro?.show()
piah890a

piah890a1#

@a158684 Caused by: java.lang.RuntimeException: Assetmanager has been closed
可以检查一下自己业务代码是否有把Assetmanager 给关闭了,刚刚用夜神模拟器实测发现无异常。

kh212irz

kh212irz2#

感谢,确实是这个问题

相关问题