2016-08-15 37 views
0

菜單欄中的溢出圖標並未出現在某些Android版本(如4.1.2)中,但在Android版本5.0,6.0中正常工作..... 也我要讓右鍵單擊共享項目應該產生那邊列表像畫廊應用程序...溢出圖標不出現在某些安卓版本(4.1.2)

下面的代碼:

first.java

@Override 
    public boolean onCreateOptionsMenu(Menu menu){ 
     getMenuInflater().inflate(R.menu.menu_main,menu); 
     return true; 
    } 

    @Override 
    public boolean onOptionsItemSelected(MenuItem item) { 
     int id = item.getItemId(); 
     if (id == R.id.action_about) { 
      Intent myIntent = new Intent(getApplicationContext(), aboutusActivity.class); 
      startActivityForResult(myIntent, 0); 
      return true; 
     } 
     if (id == R.id.share) { 
//sharing implementation here 
      Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); 
      sharingIntent.setType("text/plain"); 
      sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "आरती गणपतीची"); 
      sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "download kara from google.com/arti-sangrah"); 
      startActivity(Intent.createChooser(sharingIntent, "Share via")); 
     } 
     return super.onOptionsItemSelected(item); 
    } 

menu.x毫升

<?xml version="1.0" encoding="utf-8"?> 
<menu xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" tools:context=".first"> 

<item android:id="@+id/action_about" android:title="About Us" 
    android:orderInCategory="100" app:showAsAction="never" 
    android:src="@drawable/dot"/> 
<item android:id="@+id/share" android:title="Share" 
    android:orderInCategory="100" app:showAsAction="never" 
    android:src="@drawable/dot"/> 
</menu> 

styles.xml

<resources> 
<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 
<style name="OverFlowStyle" parent="@style/Widget.AppCompat.Light.ActionButton.Overflow"> 
    <item name="android:src">@drawable/dot</item> 
</style> 
<style name="AppTheme1" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <item name="actionOverflowButtonStyle">@style/OverFlowStyle</item> 
    <item name="android:actionOverflowButtonStyle">@style/OverFlowStyle</item> 
</style> 
</resources> 

回答

0
  1. 在第一次使用always代替never,這裏app:showAsAction="always"也可以使用ifRoom

  2. 爲第二,你只需要創建一個意圖與ACTION_SEND,我想它已經在那裏,所以如果你想要做別的試試這個link

+0

在應用程序中使用始終/ ifRoom:showAsAction導致單獨項目在操作欄中....我想從溢出圖標中顯示項目... – Devk

+0

如果您要求在操作欄中使用3點圖標,則取決於Android和設備結構。有些菜單按鈕,所以他們沒有菜單溢出圖標。 –