android-menu

Cannot instantiate class android.support.v7.widget.SearchView

给你一囗甜甜゛ 提交于 2019-12-01 02:12:08
Please somebody help me! I trying add appcompat search view to my project. Unsuccessfully. When I change android.support.v7.widget.SearchView to SearchView (API > 10) everything's fine. This my menu res: <item android:id="@+id/action_search" android:title="@string/search_view_title" android:icon="@drawable/action_search" sabd:showAsAction="always|collapseActionView" sabd:actionViewClass="android.support.v7.widget.SearchView" /> This how I try to use SeachView: @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.teach, menu); mSearchItem = menu

Using Android action bar share intent

雨燕双飞 提交于 2019-12-01 00:58:47
I'm using a menu item on the action bar and I want to share my app by clicking the share icon. When I click the share icon it doesn't work. Also, I want to add text saying "install this app" when shared. Here is my code: private ShareActionProvider mShareActionProvider; @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.mainpage, menu); MenuItem item = menu.findItem(R.id.menu_item_share); mShareActionProvider = (ShareActionProvider) item.getActionProvider(); return true; } private

Custom Menu item in Overflow menu

99封情书 提交于 2019-12-01 00:45:12
How should i make a Custom MenuItem, exactly like the first row in the menu of the attached picture ( screenshot of Google Chrome app) I have tried the below code in onCreateOptionsMenu , where R.layout.menu_top_row is the layout for the first row.But only a blank row comes up in my case? I am able to display rest of the options, but unable to display the first row. View child = getLayoutInflater().inflate(R.layout.menu_top_row, null); MenuItem menuItem=menu.add(""); menuItem.setActionView(child); Andrew Orobator Taken from this stack overflow answer : A PopupMenu is meant for displaying Menus

searchManager.getSearchableInfo(getComponentName()) returns null

那年仲夏 提交于 2019-11-30 23:53:31
问题 I've followed this Android guide in order to add a search bar to an activity. The setup looks like this: res/menu/activity_main.xml: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/search" android:title="@string/menu_search" android:icon="@android:drawable/ic_menu_search" android:showAsAction="collapseActionView|ifRoom" android:actionViewClass="android.widget.SearchView" /> <item android:id="@+id/menu_settings"

Changing text Size of menu item in android

此生再无相见时 提交于 2019-11-30 22:29:56
问题 I am using simple menu items in action bar by using following code in main activity: package com.kaasib.ftpclient; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.app.ActionBar; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu)

Android ActionBar compatibility: MenuItem.setActionView(View)

社会主义新天地 提交于 2019-11-30 20:43:46
I'm using the appcompat7 lib for ActionBar backwards compatibility. Now I have a MenuItem that I retrieve, and then want to set an ImageView myView as its icon. The way how to do it from API level 11 is: MenuItem menuItemRefresh = menu.findItem(R.id.refresh); menuItemRefresh.setActionView(myView); For API levels lower than 11 this doesn't work, the second line will show an error. Is there an option to do this in compatibility mode? Look at MenuItemCompat : http://developer.android.com/reference/android/support/v4/view/MenuItemCompat.html There is a static function setActionView(MenuItem item,

How to use custom fonts in DrawerLayout and NavigationView

拥有回忆 提交于 2019-11-30 20:38:22
I want to use Android's DrawerLayout and NavigationView for menus, but I don't know how to have the menu items use a custom font. Does anyone have a successful implementation? use this method passing the base view in your drawer public static void overrideFonts(final Context context, final View v) { Typeface typeface=Typeface.createFromAsset(context.getAssets(), context.getResources().getString(R.string.fontName)); try { if (v instanceof ViewGroup) { ViewGroup vg = (ViewGroup) v; for (int i = 0; i < vg.getChildCount(); i++) { View child = vg.getChildAt(i); overrideFonts(context, child); } }

How to use custom fonts in DrawerLayout and NavigationView

你说的曾经没有我的故事 提交于 2019-11-30 17:00:35
问题 I want to use Android's DrawerLayout and NavigationView for menus, but I don't know how to have the menu items use a custom font. Does anyone have a successful implementation? 回答1: use this method passing the base view in your drawer public static void overrideFonts(final Context context, final View v) { Typeface typeface=Typeface.createFromAsset(context.getAssets(), context.getResources().getString(R.string.fontName)); try { if (v instanceof ViewGroup) { ViewGroup vg = (ViewGroup) v; for

create new menuInflater or getMenuInflater() from activity?

半世苍凉 提交于 2019-11-30 13:07:28
I'm creating new option menu inside fragment but after reading http://developer.android.com/resources/articles/avoiding-memory-leaks.html which said to it's better to use context-application than context-activity, I'm afraid to use getActivity().getMenuInflater() So, actually which one better @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuInflater mInflater = new MenuInflater(getActivity().getApplicationContext()); mInflater.inflate(R.menu.simple_menu, menu); } Or the one call activity @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater

Android Action Bar menu not showing when target sdk version is greater than 10. Why?

走远了吗. 提交于 2019-11-30 10:06:21
I have an application wide menu that won't always show. Specifically specifically my issue is that when I set the target sdk version to 16 for devices with no hardware menu button The 3 dots (Action bar?) that should appear actua\lly don't. I have the following manifest entries <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="10" /> In an avd emulator with no hardware buttons I see the 3 dots for the action bar menu But if I set the target to 16 <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" /> No action bar appears I have styles set in various resource folders