我试着介绍长按。 这次使用alertdialog到那里的2个选项,播放和删除。 所以我想提供longpress删除和触摸播放。我该怎么办?
代码:
@Override
public void onVideoSelected(final String uri, String mimeType) {
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
builder.setTitle("Select");
// builder.setMessage("Lorem ipsum dolor ....");
builder.setItems(new CharSequence[]
{getString(R.string.play_video), getString(R.string.remove_video)},
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0:
Intent intent = new Intent(Main2Activity.this, MainActivity.class);
intent.putExtra("url", uri);
startActivity(intent);
break;
case 1:
File file = new File(uri);
file.delete();
Main2Activity.this.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(new File(uri))));
break;
}
}
});
builder.create().show();
}