Android 类型错误:未找到属性';onclick';包装内';安卓&x27;

Android 类型错误:未找到属性';onclick';包装内';安卓&x27;,android,Android,这是我的第一个应用程序,请帮助我修复此问题 类型错误:在包“android”中找不到属性“onclick”的资源标识符 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_

这是我的第一个应用程序,请帮助我修复此问题

类型错误:在包“android”中找不到属性“onclick”的资源标识符

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
    android:id="@+id/button1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:onclick='buttonBtn'
    ></Button>
 </RelativeLayout>

将此更改为

 android:onclick='buttonBtn'

资本不小吗

由于Android的XML解析器区分大小写,因此更改为:
android:onClick='buttonBtn'

在您的活动中,请执行以下操作:

public void buttonBtn(View view){ 
   //do button action here
}

错误是由于以下位置的拼写错误导致的:

  android:onClick='buttonBtn'

更改为:android:onClick='buttonBtn'这在android中称为click事件在Java文件public void buttonBtn(视图)中使用它{Toast.makeText(getApplicationContext(),“Buttan click”,1).show();}
  android:onClick='buttonBtn'