-1
既存のプロジェクトのXMLを変更するときにこのエラーが発生しました。これは私のXMLはonClick
プロパティは、このエラーを示し 対応するメソッドハンドラが見つかりません - Android XML
public class MonthViewActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_month_view);
}
public void changeMonth(View view) {
//Some methods here
}
}
MonthViewActivity.java
activity_month_view.xml
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.YearViewActivity">
<ImageView
android:id="@+id/month_view_prev_month"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_keyboard_arrow_left_black_24dp"
android:onClick="changeMonth"/>
</android.support.design.widget.CoordinatorLayout>
私のJavaクラス
のように見えたものです
Corresponding method handler 'public void changeMonth(android.view.View)' not found
私はthisとthisを見ましたが、助けにはなりませんでした。
.javaファイルに記述したメソッドがデザインウィンドウのonClickフィールドに表示されない場合は、そのXMLファイルのtools:contextを必ずチェックしてください。これは非常に重要なポインターでした。ありがとう – user3833732