0
대개 내 타블렛의 화면 모서리에 나타나는 옵션 메뉴의 아이콘을 얻으려고합니다. 거기 있지 않아! 현재 Android 4.2.2를 개발 용으로 사용하고 있습니다.옵션 메뉴 타블렛에 아이콘이 나타나지 않습니다.
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
boolean result = super.onCreateOptionsMenu(menu);
//theMenu = menu;
//new MenuInflater(getApplication()).inflate(R.menu.loggermap, menu);
menu.add(ContextMenu.NONE, MENU_TRACKING, ContextMenu.NONE, R.string.menu_tracking).setIcon(R.drawable.ic_menu_movie).setAlphabeticShortcut('T');
menu.add(ContextMenu.NONE, MENU_LAYERS, ContextMenu.NONE, R.string.menu_showLayers).setIcon(R.drawable.ic_menu_mapmode).setAlphabeticShortcut('L');
menu.add(ContextMenu.NONE, MENU_NOTE, ContextMenu.NONE, R.string.menu_insertnote).setIcon(R.drawable.ic_menu_myplaces);
menu.add(ContextMenu.NONE, MENU_STATS, ContextMenu.NONE, R.string.menu_statistics).setIcon(R.drawable.ic_menu_picture).setAlphabeticShortcut('S');
menu.add(ContextMenu.NONE, MENU_SHARE, ContextMenu.NONE, R.string.menu_shareTrack).setIcon(R.drawable.ic_menu_share).setAlphabeticShortcut('I');
menu.add(ContextMenu.NONE, MENU_TRACKLIST, ContextMenu.NONE, R.string.menu_tracklist).setIcon(R.drawable.ic_menu_show_list).setAlphabeticShortcut('P');
menu.add(ContextMenu.NONE, MENU_SETTINGS, ContextMenu.NONE, R.string.menu_settings).setIcon(R.drawable.ic_menu_preferences).setAlphabeticShortcut('C');
MenuItem noteMenu = menu.findItem(MENU_NOTE);
noteMenu.setEnabled(true);
return result;
//return (super.onCreateOptionsMenu(menu));
}
/*
* (non-Javadoc)
* @see android.app.Activity#onPrepareOptionsMenu(android.view.Menu)
*/
@Override
public boolean onPrepareOptionsMenu(Menu menu)
{
MenuItem noteMenu = menu.findItem(MENU_NOTE);
noteMenu.setVisible(true);
//noteMenu.setEnabled(mLoggerServiceManager.isMediaPrepared());
noteMenu.setEnabled(true);
MenuItem shareMenu = menu.findItem(MENU_SHARE);
shareMenu.setVisible(true);
//shareMenu.setEnabled(mTrackId >= 0);
shareMenu.setEnabled(true);
return super.onPrepareOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
boolean handled = false;
Uri trackUri;
Intent intent;
switch (item.getItemId())
{
case MENU_TRACKING:
intent = new Intent(this, ControlTracking.class);
startActivityForResult(intent, MENU_TRACKING);
handled = true;
break;
case MENU_LAYERS:
showDialog(DIALOG_LAYERS);
handled = true;
break;
case MENU_NOTE:
/*intent = new Intent(this, InsertNote.class);
startActivityForResult(intent, MENU_NOTE);*/
intent = new Intent(this, WaypointNewActivity.class);
startActivity(intent);
handled = true;
break;
case MENU_SETTINGS:
intent = new Intent(this, ApplicationPreferenceActivity.class);
startActivity(intent);
handled = true;
break;
case MENU_TRACKLIST:
intent = new Intent(this, TrackList.class);
intent.putExtra(Tracks._ID, this.mTrackId);
startActivityForResult(intent, MENU_TRACKLIST);
break;
case MENU_STATS:
if (this.mTrackId >= 0)
{
intent = new Intent(this, Statistics.class);
trackUri = ContentUris.withAppendedId(Tracks.CONTENT_URI, mTrackId);
intent.setData(trackUri);
startActivity(intent);
handled = true;
break;
}
else
{
showDialog(DIALOG_NOTRACK);
}
handled = true;
break;
case MENU_ABOUT:
intent = new Intent("org.openintents.action.SHOW_ABOUT_DIALOG");
try
{
startActivityForResult(intent, MENU_ABOUT);
}
catch (ActivityNotFoundException e)
{
showDialog(DIALOG_INSTALL_ABOUT);
}
break;
case MENU_SHARE:
intent = new Intent(Intent.ACTION_RUN);
trackUri = ContentUris.withAppendedId(Tracks.CONTENT_URI, mTrackId);
intent.setDataAndType(trackUri, Tracks.CONTENT_ITEM_TYPE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Bitmap bm = findViewById(R.id.mapScreen).getDrawingCache();
if (bm != null)
{
Uri screenStreamUri = ShareTrack.storeScreenBitmap(bm);
intent.putExtra(Intent.EXTRA_STREAM, screenStreamUri);
}
startActivityForResult(Intent.createChooser(intent, getString(R.string.share_track)), MENU_SHARE);
handled = true;
break;
case MENU_CONTRIB:
showDialog(DIALOG_CONTRIB);
default:
handled = super.onOptionsItemSelected(item);
break;
}
return handled;
}
XML 코드는 여기에 있습니다 : :
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_loggermap_tracking"
android:alphabeticShortcut="t"
android:icon="@drawable/ic_menu_movie"
android:showAsAction="ifRoom"
android:title="@string/menu_tracking"/>
<item
android:id="@+id/menu_loggermap_layers"
android:alphabeticShortcut="l"
android:icon="@drawable/ic_menu_mapmode"
android:showAsAction="ifRoom"
android:title="@string/menu_showLayers"/>
<item
android:id="@+id/menu_loggermap_note"
android:alphabeticShortcut="n"
android:icon="@drawable/ic_menu_myplaces"
android:showAsAction="ifRoom"
android:title="@string/menu_insertnote"/>
<item
android:id="@+id/menu_loggermap_stats"
android:alphabeticShortcut="s"
android:icon="@drawable/ic_menu_picture"
android:showAsAction="ifRoom"
android:title="@string/menu_statistics"/>
<item
android:id="@+id/menu_loggermap_share"
android:alphabeticShortcut="i"
android:icon="@drawable/ic_menu_share"
android:showAsAction="ifRoom"
android:title="@string/menu_shareTrack"/>
<item
android:id="@+id/menu_loggermap_tracklist"
android:alphabeticShortcut="p"
android:icon="@drawable/ic_menu_show_list"
android:showAsAction="collapseActionView"
android:title="@string/menu_tracklist"/>
<item
android:id="@+id/menu_loggermap_settings"
android:alphabeticShortcut="c"
android:icon="@drawable/ic_menu_preferences"
android:showAsAction="collapseActionView"
android:title="@string/menu_settings"/>
<item
android:id="@+id/menu_loggermap_about"
android:alphabeticShortcut="a"
android:icon="@drawable/ic_menu_info_details"
android:showAsAction="collapseActionView"
android:title="@string/menu_about"/>
<item
android:id="@+id/menu_loggermap_contrib"
android:alphabeticShortcut="o"
android:icon="@drawable/ic_menu_allfriends"
android:showAsAction="collapseActionView"
android:title="@string/menu_contrib"/>
</menu>
내가 내 자바 코드에 뭔가 문제가 있으리라 믿고있어 여기에 내가 사용하고 현재의 Java 코드입니다. 여기서 내가 뭘 잘못하고 있니? 어떤 도움을 주시면 감사하겠습니다!