4
我目前正在爲Android設計一個mp3庫。事情是,我希望用戶拿起他想添加的播放列表的名稱(有用的innit?)。因此,我在播放列表上創建了一個上下文菜單,允許用戶在3個選項中進行選擇,創建,刪除,重命名。爲什麼我要做的是在用戶點擊「創建」時顯示EditText字段,以便他可以編寫新的播放列表名稱。但是,我無法設法顯示它。下面是我對菜單進行的聽衆:Android:在菜單中顯示EditText
//creation onLongClickListener : display the menu on long lick
playlistView.setOnLongClickListener(new OnLongClickListener(){
public boolean onLongClick(View v) {
((Activity) context).openContextMenu(v);
return true;
}});
//contextMenuListener of the view
playlistView.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener(){
public void onCreateContextMenu(ContextMenu cMenu, View v, ContextMenu.ContextMenuInfo menuInfo) {
MenuInflater inflater = ((Activity) context).getMenuInflater();
inflater.inflate(R.menu.playlist_menu, cMenu);
lastLongClickedView = v;
}});
在我這樣做了menu.xml文件文件:
<item android:id="@+id/playlist_create"
android:title="Create a playlist"
>
<menu>
<EditText
android:id="@+id/playlist_choice"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:hint="@string/playlist_name"
android:lines="1"
/>
</menu>
</item>
我有一個項目嘗試,它的顯示,但EditText上。我認爲我做的錯誤是非常愚蠢的,但我不能找到它:(
感謝您的關注。
瀏覽Android中的菜單,您缺少一些基本信息 – Sandy09