【发布时间】:2016-08-15 07:22:17
【问题描述】:
菜单栏中的溢出图标在某些 android 版本(如 4.1.2)中不会出现,但在 android 版本 5.0、6.0 中可以正常工作..... 另外我想让点击共享项目应该生成一个列表,就像在画廊应用程序中一样......
代码如下:
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.xml
<?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>
【问题讨论】:
标签: java android android-resources android-styles