action bar buttons not showing
i found the solution to my problem.
since i have been trying to use namespace
xmlns:app="http://schemas.android.com/apk/res-auto"
then i should use
app:showAsAction="ifRoom"
instead of
android:showAsAction="ifRoom"
Action bar does not show
Remove your theme for your actionbar activity
in androidManifest file. Now it will work...
<application
android:allowBackup="true"
android:icon="@drawable/tasktodo"
android:label="@string/app_name"
>
Don't add any theme in your application manifest file. If you added one, please remove and try running it...
Overflow menu is not showing in Actionbar
You can also use this little hack here:
try {
ViewConfiguration config = ViewConfiguration.get(this);
Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
if(menuKeyField != null) {
menuKeyField.setAccessible(true);
menuKeyField.setBoolean(config, false);
}
} catch (Exception ex) {
// Ignore
}
Good place to put it would be the onCreate-Method of your Application class.
It will force the App to show the overflow menu. The menu button will still work, but it will open the menu in the top right corner.
As of Android 4.4, the ... affordance in the action bar will be there, regardless of whether the device has a physical MENU button or not. Google's current Compatibility Definition Document now comes out a bit more forcefully against having a dedicated MENU button.
Overflow menu's 3 dots are not showing up in ActionBar
You should need something like this.
A menu.xml
layout for the items under the res/menu
directory.
<?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">
<item
android:id="@+id/action_settings"
android:title="@string/action_settings"
app:showAsAction="never" />
...
</menu>
Then in your Activity
you must include this methods.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_settings:
// Do something
return true;
default:
return super.onOptionsItemSelected(item);
}
}
Android studio action bar not showing in new activity
try above in style.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
and update your AndroidManifest file like above
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.karanvir.search">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Main2Activity"
android:label="@string/title_activity_main2"
/>
<activity
android:name=".Yahoo"
android:label="@string/title_activity_yahoo"
></activity>
</application>
Action Button not showing in Action Bar
Change your code with the following and try again;
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
<item android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:title="@string/action_search"
yourapp:showAsAction="always" />
</menu>
Also make sure that you have the following part;
@Override
public boolean onCreateOptionsMenu( Menu menu )
{
getMenuInflater().inflate( R.menu.main, menu );
return true;
}
Related Topics
How to Set a Particular Font for a Button Text in Android
Dynamic Listview Adding "Load More Items" at the End of Scroll
Failed to Resolve Com.Android.Support:Appcompat-V7:22 and Com.Android.Support:Recyclerview-V7:21.1.2
Disable the Notification Panel from Being Pulled Down
Gradle Dsl Method Not Found: 'Runproguard'
Solving "Adb Server Version Doesn't Match This Client" Error
Onrequestpermissionsresult Not Being Called in Fragment If Defined in Both Fragment and Activity
Failed to Find Build Tools Revision 23.0.1
How to Run Code on a Background Thread on Android
Get List of Photo Galleries on Android
Removing Unused Strings During Proguard Optimisation
Creating Custom Lockscreen in Android
How to Make Notification Intent Resume Rather Than Making a New Intent
What Is the Purpose of Android's <Merge> Tag in Xml Layouts