2016-08-15 35 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和设备结构。有些菜单按钮,所以他们没有菜单溢出图标。 –