【问题标题】:Imageview doesn't display my icon in Actionbar?Imageview 不在操作栏中显示我的图标?
【发布时间】: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


【解决方案1】:

如果我理解您只需要编辑名为 menu 的文件夹中的文件。您的文件看起来像

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
   <item
     android:id="@+id/action_settings"
     android:orderInCategory="100"
     android:showAsAction="never"
     android:title="@string/action_settings"/>
</menu>

只需更改 never 并放入 always

<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<item
    android:id="@+id/action_settings"
    android:orderInCategory="100"
    android:showAsAction="always"
    android:title="@string/action_settings"/>
</menu>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多