android-actionbar

How to track the Share button clicked on the ActionBar?

╄→гoц情女王★ 提交于 2020-01-06 08:43:10
问题 I have added Share option to my ActionBarSherlock, this way: public boolean onCreateOptionsMenu(final Menu menu) { menu.add("Share") .setIcon(R.drawable.ic_title_share_default) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); } and on clicking this Icon i want to do something. how can i track the click on this ShareIcon?? 回答1: You should create an XML file to define menu items. For example mymenu.xml <?xml version="1.0" encoding="utf-8"?> <menu xmlns

ActionBar is not displaying icons in android

你。 提交于 2020-01-06 08:21:25
问题 I have been trying to display icons in the Actionbar but i could not make it up please guide me and point me out where I am going wrong. Here is my code acivity_main_actions.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"> <!-- Search / will display always --> <item android:id="@+id/action_search" android:icon="@drawable/ic_action_search" android:title="@string/action_search"

modify actionBar's appearance at runtime

一笑奈何 提交于 2020-01-06 07:00:23
问题 In my application I use an ActionBar (nether ABS nor the support action bar! minSDK = 14). The user may choose whether to use icon or text-based Tabs. I'm still facing some issues while handling the screen rotation. Basically, I have a customView set on the top (using getActionBar.setCustomView() ) in which some text and control elements are placed. In portrait mode everything works fine, but rotating the device messes up my UI. I'm posting some screenshots to illustrate the issue ( icons

(Android Studio) Custom Action Bar Layout isnt filling whole action bar

只愿长相守 提交于 2020-01-06 02:49:50
问题 before setContentView() LayoutInflater inflater = (LayoutInflater) getSupportActionBar() .getThemedContext().getSystemService(LAYOUT_INFLATER_SERVICE); View customActionBarView = inflater.inflate(R.layout.ab, null); android.support.v7.app.ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayOptions( ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); actionBar.setCustomView(customActionBarView, new android

Should the ActionBar be handled on Fragments or on the Activity?

僤鯓⒐⒋嵵緔 提交于 2020-01-06 01:46:34
问题 I am making a shopping list app, and I have two Fragments , a ProductListFragment and a ShoppingListFragment . I have ActionBar buttons to add elements to the List on ProductListFragment . My question is, should I handle these buttons on the Fragment or on the Activity? 回答1: You should allow your Activity to handle the events of your fragments. This allows you flexibility in your design so that you can reuse your fragments in other Activities down the line. Here is a great example of how to

Error inflating class android.support.v7.internal.view.menu.ActionMenuItemView, android?

不问归期 提交于 2020-01-05 14:28:42
问题 I am getting this error on inflating the menu Logcat: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.v7.internal.view.menu.ActionMenuItemView at android.view.LayoutInflater.createView(LayoutInflater.java:620) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) at android.view.LayoutInflater.inflate(LayoutInflater.java:469) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.support.v7.internal.view

Android Material Design navigation drawer menu icon chage

旧街凉风 提交于 2020-01-05 14:12:46
问题 I implemented a Material Design nav drawer using this example. I customize it according to my theme. Everything is working perfectly. Just the last thing I want to customize it's menu icon. I googled it, but have not find any good solution. I want to change its color if possible , or add a custom drawable. Any solution on idea. Thanks in advance This is my Application theme which i set in menifest <style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar"> <item name=

Set image in action bar

半腔热情 提交于 2020-01-05 08:28:59
问题 I have set image in Actionbar using ActionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.header)); and also removed "android:icon="@drawable/header" from manifest.xml but I am getting one image overlapped over other. I am attaching snapshot. I want to display only my image. 回答1: getActionBar().setDisplayShowHomeEnabled(false); add this in your code you will get the desired output!!! 回答2: Use this code: getActionBar().setIcon(android.R.color.transparent); 来源: https:/

Action Bar Select All/Cut/Copy not showing for alert dialog

倖福魔咒の 提交于 2020-01-05 06:52:30
问题 Action Bar Select All/Cut/Copy not showing for EditText in Alert dialog(picture 2),Kindly help Edit: the code is View view = MainActivity.this.getLayoutInflater().inflate( R.layout.custom_dialog, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( MainActivity.this); alertDialogBuilder.setView(view); alertDialogBuilder.setPositiveButton("Add", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); alertDialogBuilder

android.support.v7 Toolbar & DrawerLayout- how to change Hamburger icon

陌路散爱 提交于 2020-01-05 03:52:05
问题 My application uses ActionBarActivity and DrawerLayout and etc. i want to change the ActionBarDrawerToggle icon to be custom drawable. in my code i use android.support.v7.widget.Toolbar as SupportActionBar this is my code: toolbar.setNavigationIcon(R.drawable.lifeline_shield); setSupportActionBar(toolbar); ActionBar actionbar = getSupportActionBar(); actionbar.setDisplayHomeAsUpEnabled(true); actionbar.setDisplayShowTitleEnabled(false); mDrawerToggle = new ActionBarDrawerToggle(this,