ユーザーが画像をクリックして、クリックされた同じビューでアップロードする画像を選択できる機能を開発しようとしています。ImageView を次のように定義します。
<ImageView
style = "@style/DefaultButton"
android:id="@+id/choose_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="46dp"
android:clickable="True"
android:adjustViewBounds="true"
android:onClick="chooseImg"
android:contentDescription="@string/description_logo"
android:src="@drawable/user2" />
メソッド chooseImg は次のとおりです。
public void chooseImg(View view){
Toast.makeText(this, "Choose Image from Gallery", Toast.LENGTH_SHORT).show();
Intent chimg = new Intent(Intent.ACTION_GET_CONTENT);
chimg.setType("image/*");
startActivityForResult(chimg,CHOOSE_IMAGE_REQUEST_CODE);
}
メソッドは呼び出されていません。理由を知るために私を助けてください。ありがとう :)。