gpt4 book ai didi

android - UI 组件的 API 版本

转载 作者:行者123 更新时间:2023-11-29 22:04:06 25 4
gpt4 key购买 nike

我正在使用 ActionBarSherlock 组件开发应用程序。我的目标是针对 8 级 API 之后的所有设备。当我尝试膨胀以下 xml 时,我在运行 android 2.2.1(级别 8)的设备上遇到异常。

我不知道哪个组件不正常。你们能帮帮我吗?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ImageView
android:id="@+id/albumImg"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/button" />

<TextView
android:id="@+id/albumStatic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Album :"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />

<TextView
android:id="@+id/albumTitle"
style="@android:style/TextAppearance.Holo.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/albumStatic"
android:layout_toLeftOf="@+id/albumImg"
android:text="(not found)" />

<TextView
android:id="@+id/albumStatic"
style="@android:style/TextAppearance.Holo.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Album :"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />

<TextView
android:id="@+id/artistStatic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/albumTitle"
android:text="Artiste : "
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />

<TextView
android:id="@+id/artistName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="@+id/albumTitle"
android:layout_below="@+id/artistStatic"
android:text="(not found)" />


<LinearLayout
android:id="@+id/tagsContainer"
android:layout_width="match_parent"
android:layout_height="35dip"
android:layout_alignParentLeft="true"
android:layout_below="@+id/albumImg"
android:gravity="center_vertical"
android:orientation="horizontal" >







<HorizontalScrollView
android:id="@+id/tagsScrollView"
android:layout_width="wrap_content"
android:layout_height="32dip"
android:layout_below="@+id/albumImg"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center_vertical" >

<LinearLayout
android:id="@+id/tagsLayout"
android:layout_width="wrap_content"
android:layout_height="32dip"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_gravity="center_vertical" >

<TextView
android:id="@+id/tags_static"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tags : "
android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
android:id="@+id/tags_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="(none)" />

</LinearLayout>
</HorizontalScrollView>
<View
android:id="@+id/vertical_divider"
android:layout_width="1dip"
android:layout_height="match_parent"
android:paddingLeft="16dip"
android:paddingRight="16dip"
android:background="?android:attr/dividerVertical" />


<ImageButton

android:id="@+id/BT_editTags"
android:layout_width="wrap_content"
android:layout_height="32dip"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:layout_gravity="center_vertical"
android:background="?android:attr/selectableItemBackground"
android:src="@android:drawable/ic_menu_edit" />

</LinearLayout>

<TextView
android:id="@+id/tracks_static"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/tagsContainer"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="Tracks"
android:textAppearance="?android:attr/textAppearanceLarge" />

<ListView
android:id="@+id/tracksListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/tracks_static" >

<!-- Preview: listitem=@android:layout/simple_list_item_1 -->
</ListView>



<TextView
android:id="@+id/dateStatic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/albumImg"
android:layout_alignParentLeft="true"
android:layout_below="@+id/artistName"
android:text="Date : "
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />


<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/dateStatic"
android:layout_alignBottom="@+id/dateStatic"
android:layout_alignRight="@+id/artistName"
android:layout_toRightOf="@+id/dateStatic"
android:text="(not found)" />

</RelativeLayout>

</LinearLayout>

错误日志提到找不到滚动条。但我很确定 Horizo​​ntalScrollView 和 listView 存在于 API 8 上,不是吗?

这里是错误:

06-27 17:11:20.817: E/AndroidRuntime(2064): FATAL EXCEPTION: main
06-27 17:11:20.817: E/AndroidRuntime(2064): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.micky.scanthings/com.micky.scanthings.ScanView}: android.view.InflateException: Binary XML file line #121: Error inflating class android.view.View
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2753)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.app.ActivityThread.access$2500(ActivityThread.java:129)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2117)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.os.Handler.dispatchMessage(Handler.java:99)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.os.Looper.loop(Looper.java:143)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.app.ActivityThread.main(ActivityThread.java:4717)
06-27 17:11:20.817: E/AndroidRuntime(2064): at java.lang.reflect.Method.invokeNative(Native Method)
06-27 17:11:20.817: E/AndroidRuntime(2064): at java.lang.reflect.Method.invoke(Method.java:521)
06-27 17:11:20.817: E/AndroidRuntime(2064): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
06-27 17:11:20.817: E/AndroidRuntime(2064): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-27 17:11:20.817: E/AndroidRuntime(2064): at dalvik.system.NativeStart.main(Native Method)
06-27 17:11:20.817: E/AndroidRuntime(2064): Caused by: android.view.InflateException: Binary XML file line #121: Error inflating class android.view.View
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
06-27 17:11:20.817: E/AndroidRuntime(2064): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
06-27 17:11:20.817: E/AndroidRuntime(2064): at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:857)
06-27 17:11:20.817: E/AndroidRuntime(2064): at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:251)
06-27 17:11:20.817: E/AndroidRuntime(2064): at com.micky.scanthings.ScanView.onCreate(ScanView.java:58)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2717)
06-27 17:11:20.817: E/AndroidRuntime(2064): ... 11 more
06-27 17:11:20.817: E/AndroidRuntime(2064): Caused by: java.lang.reflect.InvocationTargetException
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.view.View.<init>(View.java:1850)
06-27 17:11:20.817: E/AndroidRuntime(2064): at java.lang.reflect.Constructor.constructNative(Native Method)
06-27 17:11:20.817: E/AndroidRuntime(2064): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
06-27 17:11:20.817: E/AndroidRuntime(2064): ... 25 more
06-27 17:11:20.817: E/AndroidRuntime(2064): Caused by: android.content.res.Resources$NotFoundException: File res/drawable-hdpi/scrollbar_handle_vertical.9.png from drawable resource ID #0x0
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.content.res.Resources.loadDrawable(Resources.java:1714)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.view.View.<init>(View.java:1901)
06-27 17:11:20.817: E/AndroidRuntime(2064): ... 29 more
06-27 17:11:20.817: E/AndroidRuntime(2064): Caused by: java.io.FileNotFoundException: res/drawable-hdpi/scrollbar_handle_vertical.9.png
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.content.res.AssetManager.openNonAssetNative(Native Method)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.content.res.AssetManager.openNonAsset(AssetManager.java:418)
06-27 17:11:20.817: E/AndroidRuntime(2064): at android.content.res.Resources.loadDrawable(Resources.java:1706)
06-27 17:11:20.817: E/AndroidRuntime(2064): ... 31 more

编辑:这是由于 ?android:attr/dividerVertical?android:attr/dividerVertical(也许除其他外,比如 Holo 主题)。

最佳答案

查看堆栈跟踪的最底部:

Caused by: java.io.FileNotFoundException: res/drawable-hdpi/scrollbar_handle_vertical.9.png

看起来您在 drawable-hdpi 文件夹中缺少一个 png 文件。

关于android - UI 组件的 API 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11229657/

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