2013-09-21 37 views
1

的「onClick」這是我的第一個應用程序,請幫我解決這個類型錯誤:未找到屬性資源標識符包「機器人」

類型錯誤:未找到屬性的「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> 
+0

更改爲:安卓的onClick = 'buttonBtn' 在Android中使用它這就是所謂的Click事件中的Java文件 公共無效buttonBtn(查看視圖) { Toast.makeText(getApplicationContext(),「Buttan點擊「,1).show(); } –

回答

0

更改爲

android:onclick='buttonBtn' 

android:onClick='buttonBtn' 

c是資本不小

由於Android的XML解析器是大小寫敏感的

0

更改爲: android:onClick='buttonBtn'

,並在您的活動,這樣做:

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

錯誤造成由於拼寫錯誤,在

android:onClick='buttonBtn' 
相關問題