Android UnsupportedOperationException异常

从一个Activity跳到另一个Activity,页面加载时出现了以下错误:java.lang.RuntimeException: Unable to start activity ComponentInfo{cn.bzu.mydiary/cn.bzu.mydiary.LoginActivity1}: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12

页面源码为:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/login"
    android:orientation="vertical"
    tools:content=".LoginActivity1" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/login"
        android:textColor="#7FFFD4" />

 	 <EditText
        android:id="@+id/uname"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/password"
        android:textColor="#7FFFD4" />

    <EditText
        android:id="@+id/upass"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>
    <Button
        android:id="@+id/yes"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/login" />

    <Button
        android:id="@+id/no"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@id/yes"
        android:text="@string/quxiao" />

</LinearLayout>


找了很多资料最终解决,由于android:layout_marginLeft属性的问题,只要删除页面设计中的带有其的语句即可正常运行。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Android 13中的UnsupportedOperationException是一个运行时异常,通常发生在尝试执行不支持的操作时。当应用程序试图执行一个不支持的操作或功能时,该异常将被抛出。 这种异常通常在以下情况下发生: 1. 使用不支持的API:可能是因为应用程序使用了过时的Android API或尝试使用了不适用于当前设备或Android版本的API。 2. 错误的方法调用:可能是因为应用程序试图调用一个不支持的方法或属性。例如,尝试在未授权的位置访问设备文件系统时会抛出该异常。 3. 逻辑错误:可能是因为在代码中发生了逻辑错误,导致不支持的操作被执行。 为了解决Android 13 UnsupportedOperaionException异常,可以采取以下步骤: 1. 检查代码中的API调用:确保应用程序使用的API是适用于目标设备和Android版本的。在编写应用程序时,应使用最新的API,并仔细检查过时的方法和属性。 2. 检查权限:如果应用程序需要访问受限资源,如设备文件系统或传感器,需要确保已正确申请和获取相关权限。 3. 调试代码:通过调试和跟踪应用程序的执行流程,可以找到可能导致UnsupportedOperaionException异常的逻辑错误。检查代码中可能导致异常的部分,并修复问题。 总之,UnsupportedOperaionException异常通常发生在尝试执行不支持的操作时。为了解决此异常,需要仔细检查应用程序的代码并确保使用适用于目标设备和Android版本的API,并正确申请所需的权限。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值