我是新来编码,现在创建一个Android应用程序,其中有一些视频下的视频选项卡/列表,我的问题是如何添加删除(与通知),共享,取消按钮,当我长按特定我想删除的视频(从内部存储器)?用例子指导我。在全新这个:)如何在longpress上添加删除,共享,取消按钮?
的minSdkVersion = “11” targetSdkVersion = “25”
搜查,但没有发现有任何的例子恰当的答案,但..
渴望学习: (
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
switch(item.getItemId()) {
case R.id.deletevideo:
// add stuff here
return true;
case R.id.sharevideo:
// edit stuff here
return true;
case R.id.cancelvideo:
// remove stuff here
return true;K
default:
return super.onContextItemSelected(item);
}
}
}
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity" >
<item
android:id="@+id/deletevideo"
android:icon="@android:drawable/ic_menu_add"
android:title="@string/video_delete"/>
<item
android:id="@+id/sharevideo"
android:icon="@android:drawable/ic_menu_edit"
android:title="@string/video_share"/>
<item
android:id="@+id/cancelvideo"
android:title="@string/video_Cancel"/>
</menu>
请按照以下引用的http://www.vogella。 com/tutorials,那么你可以开始编码。 –
我会检查它bro –