2016-07-02 3 views
0

레이아웃에 버튼이 두 개 있습니다. 하나는 (연락처) 다른 (buy_coins)하지 않습니다. 나는 다음과 같은 오류 메시지가 나타날 버튼을 클릭하면메서드가 있지만 java.lang.IllegalStateException : 메서드를 찾을 수 없습니다.

activity_main.xml 

... 
<Button 
    android:id="@+id/Button2" 
    android:background="@null" 
    android:text="Contacts" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:onClick="contacts"/> 

<Button 
    android:id="@+id/Button3" 
    android:background="@null" 
    android:text="Purchase Coins" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:onClick="buy_coins"/> 

MainActivity.java 
... 
    public void contacts(View v) { 
    Intent intent = new Intent(this, Contacts.class); 
    startActivity(intent); 
    } 

    public void buy_coins(View v) { 
    Intent intent = new Intent(this, BuyCoins.class); 
    startActivity(intent); 
    } 

을 :

java.lang.IllegalStateException: Could not find method buy_coins(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatButton with id 'Button3'

활동 내 AndroidManifest를 파일에 포함되어 다음과 같이 내 activity_main 레이아웃 파일 및 MainActivity.java 파일입니다.

+0

밑줄을 제거하면 어떻게됩니까? – Lino

답변

0

BuyCoins 활동의 setContentView가 잘못되었습니다.

관련 문제