【发布时间】:2014-08-26 23:43:03
【问题描述】:
我有一个简单的图像查看应用程序...假设在 viewpager 模式下显示图像。但是,我的问题是它没有在操作栏的顶部显示我的应用程序图标......任何帮助将不胜感激......我知道它非常小,但我无法发现它。 .我想显示我的图标,如link 所示
请看我下面的代码...
Mainactivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate menu resource file.
getMenuInflater().inflate(R.menu.activity_main, menu);
// Locate MenuItem with ShareActionProvider
MenuItem item = menu.findItem(R.id.menu_item_share);
// Fetch and store ShareActionProvider
mShareActionProvider = (ShareActionProvider) item.getActionProvider();
// Return true to display menu
return true;
}
// Call to update the share intent
private void setShareIntent(Intent shareIntent) {
if (mShareActionProvider != null) {
mShareActionProvider.setShareIntent(shareIntent);
}
}
@Override
protected void onPause() {
super.onPause();
oursong.release();
}
}
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:icon="@drawable/icon" >
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:icon="@drawable/icon" />
</RelativeLayout>
Manifest.xml
<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<!-- Splash screen -->
<activity
android:name="com.manishkpr.viewpagerimagegallery.SplashScreen"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Main activity -->
<activity
android:name="com.manishkpr.viewpagerimagegallery.MainActivity"
android:label="@string/app_name"
android:icon="@drawable/icon">
</activity>
</application>
</manifest>
【问题讨论】:
-
张贴一张图片,它的样子和你想要的样子。图片链接。
-
@Rod_Algonquin ...感谢您的回复..请查看我编辑的链接..查看我想要的操作栏..带有我的图标..
-
你的意思是安卓图标??你也可以张贴现在的样子吗
-
@Rod_Algonquin ....是的,只是普通的android图标..对不起,我无法发布图片....我不知道为什么我的模拟器无法正常工作.... ..
-
在你的清单中试试这个
ic_launcher作为图标
标签: android xml icons manifest