android-actionbar

Failed to load AppCompat ActionBar with unknown error android studio 3.0

浪尽此生 提交于 2019-12-17 20:51:19
问题 After updating android studio to version 3.0, I can't preview layout of my app, I get the error like: 'Failed to load AppCompat ActionBar with unknown error'. How can I fix this? but if I run the app on my device phone, its run normally. This is my Gradle file: apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion '26.0.2' defaultConfig { applicationId 'com.halloo' minSdkVersion 16 targetSdkVersion 24 versionCode 1 versionName "1.0" testInstrumentationRunner

Detect click on Actionbar's Overflow menu button

ε祈祈猫儿з 提交于 2019-12-17 19:46:50
问题 Can I detect click/tap on the menu button of action bar, i.e. used to show overflow menu items? By default it opens up the list with one item "Settings". Here is the screenshot: Until now it is detecting click on "2" but I want to detect click on "1". 回答1: To detect the click on the overflow menu have such code: @Override public boolean onMenuOpened(int featureId, Menu menu) { if(featureId == AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR && menu != null){ //overflow menu clicked, put code here

Reuse the Action Bar in all the activities of app

僤鯓⒐⒋嵵緔 提交于 2019-12-17 19:44:53
问题 I am a newbie to android and I was wondering if someone could guide me about how to reuse the action bar in all of my android activities. As far as I have explored, I found out that we have to make a BaseActivity class and extend it in our Activity where we want to reuse it, and also we have to make a xml layout and include it in our activity xml file. I have finished with the BaseActivity part. Now I am sort of confused in framing the xml part and including it. I know how to merge and

Adding an action bar to Theme.Black.NoTitleBar Android

旧巷老猫 提交于 2019-12-17 19:25:43
问题 I'm trying to add the action bar programatically as shown in the dev documentaion but I'm coming across an error. My minSdk is set to 11, my application has one layout and one activity and the only code in the activity is: @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.inbox); ActionBar actionBar = getActionBar(); actionBar.show(); } If I take out those last two lines then my app

Android: Change color of line below ActionBar

半城伤御伤魂 提交于 2019-12-17 19:00:00
问题 I want to change the color of the orange line below the ActionBar. I've tried a few things but nothing has helped so far. The current theme on my Galaxy S2 is an orange theme. So changing the theme, also changes the line. But I don´t know how to get access to that line, in order to change the color. 回答1: You can use This code for achieving your purpose. background.xml <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape

How change position of popup menu on android overflow button?

拟墨画扇 提交于 2019-12-17 18:57:48
问题 I just like to implement somethings same as popup menu in the Gmail app, anchored to the overflow button at the top-right. for that I used the same code as google tutorial for android Android popup menu, but for me show pop menu on top of edge of actionbar not under that. If you notice on pop menu of gmail overflow you saw that popmenu take place at edge of actionbar. This is the xml that I used for popup menu: <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android

How to make android action bar title center aligned?

醉酒当歌 提交于 2019-12-17 18:56:08
问题 I tried my own Custom Action bar for getting action bar title centered on the middle. It worked. However, after I added the options menu in Action bar, the title again shifted to the left. What should I do in order to get the title centered on the middle of the action bar? my code is: ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayUseLogoEnabled

NavigationDrawer using only Android Support Library

时间秒杀一切 提交于 2019-12-17 18:44:50
问题 is there any example project which use only Android Support Library (revision 18) to implement Navigation Drawer on Android +2.2 without using any additional library (ABS etc.) ? Here is the example which use ASL but it's work only on API +14 : http://developer.android.com/training/implementing-navigation/nav-drawer.html . Here is my MainActivity: package com.example.android.navigationdrawerexample; import java.util.Locale; import android.app.Activity; //import android.app.Fragment; //import

How to get onClickListener() event on custom actionbar

随声附和 提交于 2019-12-17 18:38:59
问题 I'm developing an application in which I have to get onClick() event on click of actionbar custom view. So far I'm able to achieve the following layout. Here is my code for achieving this: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); getActionBar().setCustomView(R.layout.custom_image_button); getActionBar()

Upgrading to SDK 21 - Error inflating class android.support.v7.internal.widget.ActionBarContainer

半世苍凉 提交于 2019-12-17 18:35:41
问题 I'm trying to upgrade my app from API19 to API21 The main changes I've made to the gradle properties are: compileSdkVersion 21 buildToolsVersion "21.0.2" minSdkVersion 8 targetSdkVersion 21 compile 'com.android.support:appcompat-v7:21.0.0' The app builds ok, but I always get the following error: 10-22 23:10:38.867 7972-8058/com.example.android.demo E/ACRA? com.example.android.demo fatal error : Unable to start activity ComponentInfo{com.example.android.demo/com.example.android.demo