无法转换为维度:类型=为0x1在Android 4.1上运行的应用程序时, [英] Can't convert to dimension: type=0x1 when running app on Android 4.1

查看:247
本文介绍了无法转换为维度:类型=为0x1在Android 4.1上运行的应用程序时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我开始使用经典的Andr​​oid虚拟设备genymotion代替,但我有它的一些问题.. 当我尝试运行我的应用程序我得到这个错误。

I recently started to use genymotion instead of classic Android virtual device, but I have some issues with it.. When I try to run my app I got this error.

Can't convert to dimension: type=0x1

我来自LayoutInflater..When我Genymotion运行它,它说,有一些设计参数有坏type..below从机器人工作室的两张截图。第一已采取运行在Nexus 4该应用时,第二个是从Genymotion。

I comes from LayoutInflater..When I run it in Genymotion it says that there is some layout param which has bad type..below are two screenshots from android studio. The first has been taken when running the app on Nexus 4 and the second one is from Genymotion.

这两个应该运行果冻豆,唯一的区别是,Genymotion是API 16,而Nexus的4运行最新的4.2.2,因此API 17 ..

Both should be running Jelly Bean, the only difference is that Genymotion is on API 16, while Nexus 4 runs up to date on 4.2.2, thus API 17..

的问题来自于我的自定义列表视图适配器 - 从getView方法,所以我认为它必须与这些布局之一。 (我有两种不同类型的列表项)

The problems comes from my custom list view adapter - from its getView method, so I think it must be related to one of those layouts. (I have two different types of list items)

list_heading.xml

list_heading.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="wrap_content">


<TextView
        android:id="@+id/listViewHeaderText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="8dp"
        android:paddingTop="10dp"
        android:paddingBottom="3dp"
        android:text="Nacionále"
        android:textAppearance="?android:attr/listSeparatorTextViewStyle"
        android:textColor="@color/main_cvut"/>


<RelativeLayout
        android:id="@+id/listViewHeaderLine"
        android:layout_width="fill_parent"
        android:layout_height="1dip"
        android:background="@color/main_cvut"/>
</LinearLayout>

list_item.xml

list_item.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/listItem"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/list_item_layout"
            android:clickable="true"
            android:focusable="true"
            android:paddingTop="?android:attr/listPreferredItemPaddingStart"
            android:minHeight="?android:attr/listPreferredItemHeight">

<TextView
        android:id="@+id/itemTitle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Title"
        android:paddingRight="?android:attr/listPreferredItemPaddingRight"
        android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
        android:textAppearance="?android:attr/textAppearanceMedium"/>

<TextView
        android:id="@+id/itemDescription"
        android:textColor="@android:color/darker_gray"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="description"
        android:paddingRight="?android:attr/listPreferredItemPaddingRight"
        android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
        android:textAllCaps="true"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:layout_marginBottom="?android:attr/listPreferredItemPaddingEnd"
        android:paddingBottom="?android:attr/listPreferredItemPaddingRight"
        android:layout_below="@+id/itemTitle"/>

<ImageView
        android:id="@+id/itemIcon"
        android:layout_width="32dp"
        android:layout_height="32dp"
        android:layout_alignParentEnd="true"
        android:layout_marginRight="16dp"
        android:layout_centerVertical="true"
        android:layout_alignParentStart="true"/>

<RelativeLayout
        android:id="@+id/itemBottomLine"
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:layout_alignParentBottom="true"
        android:layout_marginTop="?android:attr/listPreferredItemPaddingEnd"
        android:background="#b5b5b5"
        android:layout_alignParentEnd="false"/>
</RelativeLayout>

我试图删除所有这些引用的补白,利润率,..但它已在LL没有效果.. 我也试着用API 16运行在标准的Andr​​oid模拟器,它也不会work..Please你能告诉我这本code部分不与该版本兼容?

I tried to delete all of those referenced paddings, margins,.. But it has had no effect at ll.. I also tried to run it in standard android emulator with API 16 and it also does not work..Please could you tell me which part of this code is not compatible with that version?

推荐答案

总是看API级别的属性:

Always look at the API Level for an attribute:

<RelativeLayout
    ...
    ...
    android:layout_alignParentEnd="false"/>

安卓layout_alignParentEnd中添加了API级17

android:layout_alignParentEnd was added in API level 17

http://developer.android.com/reference/android/widget/RelativeLayout.html#ALIGN_PARENT_END

这篇关于无法转换为维度:类型=为0x1在Android 4.1上运行的应用程序时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆