Issue
I faced with the weird issue.
When I use android holo theme as default theme, and then selecting text on webview, the contextual action bar show correctly.
<style name="MyTheme" parent="Theme.AppCompat.Light">
</style>

But when I use app compact holo theme, the select all and copy action are gone.
<style name="MyTheme" parent="android:Theme.Holo.Light">
</style>

Where is my problem? My app supports android devices 4.0+
Solution
Because in your menu.xml file you use atribute app:showAsAction="ifRoom" for not app commpat theme.
Please change app:showAsAction="ifRoom" to android:showAsAction="ifRoom" and should work
Example
For this style
<style name="AppTheme" parent="android:Theme.Holo.Light">
works below menu
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<item android:id="@+id/pase"
android:title="@string/action_settings"
android:orderInCategory="100"
android:icon="@drawable/abc_ic_menu_paste_mtrl_am_alpha"
//look here is a different
android:showAsAction="ifRoom"/>
<item android:id="@+id/copy"
android:title="@string/action_settings"
android:icon="@drawable/abc_ic_menu_copy_mtrl_am_alpha"
android:orderInCategory="100"
android:showAsAction="ifRoom"/>
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"
android:showAsAction="never"/>
</menu>
For this style
<style name="AppTheme" parent="Theme.AppCompat.Light">
works below menu
<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=".MainActivity">
<item android:id="@+id/pase"
android:title="@string/action_settings"
android:orderInCategory="100"
android:icon="@drawable/abc_ic_menu_paste_mtrl_am_alpha"
//look here is a different
app:showAsAction="ifRoom"/>
<item android:id="@+id/copy"
android:title="@string/action_settings"
android:icon="@drawable/abc_ic_menu_copy_mtrl_am_alpha"
android:orderInCategory="100"
app:showAsAction="ifRoom"/>
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"
app:showAsAction="never"/>
</menu>
Additionally if you use Theme.AppCompat.Light you should use ActivityActionBar in your code.
Answered By - Konrad Krakowiak
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.