gpt4 book ai didi

java - 当我在 android 6.0 上运行时,我在微调器上收到错误。但相同的代码适用于 Android 版本 7、8、9

转载 作者:太空宇宙 更新时间:2023-11-04 09:10:28 26 4
gpt4 key购买 nike

我正在使用 Spinner 来显示一些值。

Its working on other newest android version like 7, 8, 9. But I got an error on android version android 6.0

01-13 16:40:14.010 11363-11363/in.codepoetry.callrecordapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: in.codepoetry.callrecordapp, PID: 11363
java.lang.RuntimeException: Unable to start activity ComponentInfo{in.codepoetry.callrecordapp/in.codepoetry.callrecordapp.CRE_Selector}: android.view.InflateException: Binary XML file line #45: Binary XML file line #45: Error inflating class Spinner
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2487)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2547)
at android.app.ActivityThread.access$1100(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1398)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5604)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
Caused by: android.view.InflateException: Binary XML file line #45: Binary XML file line #45: Error inflating class Spinner
at android.view.LayoutInflater.inflate(LayoutInflater.java:543)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at in.codepoetry.callrecordapp.CRE_Selector.onCreate(CRE_Selector.java:43)
at android.app.Activity.performCreate(Activity.java:6358)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2440)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2547) 
at android.app.ActivityThread.access$1100(ActivityThread.java:151) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1398) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:157) 
at android.app.ActivityThread.main(ActivityThread.java:5604) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) 
Caused by: android.view.InflateException: Binary XML file line #45: Error inflating class Spinner
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:786)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:708)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:839)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:842)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:842)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802)
at android.view.LayoutInflater.inflate(LayoutInflater.java:519)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at in.codepoetry.callrecordapp.CRE_Selector.onCreate(CRE_Selector.java:43) 
at android.app.Activity.performCreate(Activity.java:6358) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2440) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2547) 
at android.app.ActivityThread.access$1100(ActivityThread.java:151) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1398) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:157) 
at android.app.ActivityThread.main(ActivityThread.java:5604) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) 
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/spiner_bg.xml from drawable resource ID #0x7f070093
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2690)
at android.content.res.Resources.loadDrawable(Resources.java:2580)
at android.content.res.MiuiResources.loadDrawable(MiuiResources.java:388)
at android.content.res.TypedArray.getDrawable(TypedArray.java:872)
at android.view.View.<init>(View.java:3963)
at android.view.ViewGroup.<init>(ViewGroup.java:574)
at android.widget.AdapterView.<init>(AdapterView.java:246)
at android.widget.AbsSpinner.<init>(AbsSpinner.java:70)
at android.widget.Spinner.<init>(Spinner.java:232)
at android.widget.Spinner.<init>(Spinner.java:199)
at android.widget.Spinner.<init>(Spinner.java:154)
at androidx.appcompat.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:196)
at androidx.appcompat.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:167)
at androidx.appcompat.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:148)
at androidx.appcompat.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:133)
at androidx.appcompat.app.AppCompatViewInflater.createSpinner(AppCompatViewInflater.java:197)
at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:118)
at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1266)
at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1316)
at android.view.LayoutInflater.

这是我将数据放入微调器的代码

ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(CRE_Selector.this,android.R.layout.simple_spinner_item, Customer);

dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

customer_list.setAdapter(dataAdapter);

这是我的 spiner_bg.xml



<item>
<shape android:shape="rectangle" >
<solid android:color="@android:color/transparent" />
</shape>
</item>

<item android:top="-2dp" android:right="-2dp" android:left="-2dp">
<shape>
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="#ababb2" />
</shape>
</item>
<item>
<bitmap android:gravity="right"
android:src="@drawable/drop" />
// you can use any other image here, instead of default_holo_dark_am
</item>

</layer-list>

最佳答案

检查此原因:android.content.res.Resources$NotFoundException:来自可绘制资源 ID #0x7f070093 的文件 res/drawable/spiner_bg.xml

更改此资源文件即可解决此问题

关于java - 当我在 android 6.0 上运行时,我在微调器上收到错误。但相同的代码适用于 Android 版本 7、8、9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59715696/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com