簡體   English   中英

Imageview在操作欄中沒有顯示我的圖標?

[英]Imageview doesn't display my icon in Actionbar?

我有一個簡單的圖像查看應用程序...假定以viewpager模式顯示圖像。 但是,我的問題是它沒有在操作欄頂部顯示我的應用程序圖標...任何幫助將不勝感激.....我知道它確實很小,但是我找不到它。我想顯示我的圖標,如此鏈接所示

請查看我的以下代碼...

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>

據我了解,您只需要在名為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>

而只是改變從來沒有 ,並把

<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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM