0
上午在Android相機應用程序上工作時,我點擊它保存圖像時,我在畫廊上點擊畫廊查看它顯示默認畫廊的移動,但我想要自己的自定義視圖按鈕像刪除,共享,最喜歡。我該如何執行此操作請幫助我如何使自己的自定義相機畫廊視圖
public void clickedGallery(View view) {
if (MyDebug.LOG)
Log.d(TAG, "clickedGallery");
//Intent intent = new Intent(Intent.ACTION_VIEW, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
Uri uri = null;
Media media = getLatestMedia();
if (media != null) {
uri = media.uri;
}
if (uri != null) {
// check uri exists
if (MyDebug.LOG)
Log.d(TAG, "found most recent uri: " + uri);
try {
ContentResolver cr = getContentResolver();
ParcelFileDescriptor pfd = cr.openFileDescriptor(uri, "r");
if (pfd == null) {
if (MyDebug.LOG)
Log.d(TAG, "uri no longer exists (1): " + uri);
uri = null;
}
pfd.close();
} catch (IOException e) {
if (MyDebug.LOG)
Log.d(TAG, "uri no longer exists (2): " + uri);
uri = null;
}
}
if (uri == null) {
uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
}
if (!is_test) {
// don't do if testing, as unclear how to exit activity to finish test (for testGallery())
if (MyDebug.LOG)
Log.d(TAG, "launch uri:" + uri);
final String REVIEW_ACTION = "com.android.camera.action.REVIEW";
try {
// REVIEW_ACTION means we can view video files without autoplaying
Intent intent = new Intent(REVIEW_ACTION, uri);
this.startActivity(intent);
} catch (ActivityNotFoundException e) {
if (MyDebug.LOG)
Log.d(TAG, "REVIEW_ACTION intent didn't work, try ACTION_VIEW");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
// from http://stackoverflow.com/questions/11073832/no-activity-found-to-handle-intent - needed to fix crash if no gallery app installed
//Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("blah")); // test
if (intent.resolveActivity(getPackageManager()) != null) {
this.startActivity(intent);
} else {
preview.showToast(null, R.string.no_gallery_app);
}
}
}
}
感謝答覆,但實際上我想ImageView的不是當我點擊保存點擊的形象它的預覽顯示,我們可以向左或向右滑動圖庫視圖 –