非常に単純なことでエラーが発生します。レイアウトを変更するためにテストボタンとonClickメソッドを作成しました。あなたが私の問題をよりよく理解できるように、簡単な方法でそれを行いました。親または祖先のコンテキストでOnclickメソッドが見つかりません
これは私のボタン方式
public void accountButton (View v){
setContentView(R.layout.activity_start);
}
であり、これは私がボタン
のjavaをクリックしたときに、私は次のエラーを取得する私のボタンのxmlファイル
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Test" android:id="@+id/button" android:layout_below="@+id/welcomeTxt" android:layout_centerHorizontal="true" android:layout_marginTop="149dp" android:onClick="accountButton" android:nestedScrollingEnabled="true" />
です。 lang.IllegalStateException:親または祖先の accountButton(View)を見つけることができませんでしたのコンテキストアンドロイド:onClickのidを持つビュークラス android.support.v7.widget.AppCompatButtonに定義された属性 'ボタン'
もあなたのアクティビティコードを投稿してください。 –