android-actionbar

Android Action Bar: Can I replace a custom Title in appcompat v7

我们两清 提交于 2019-12-04 04:29:44
问题 I want to add a custom action title on the left of the actin bar, replacing with the default title just like in the below image the default image is shown And here I want to add this title. 回答1: You need to change the logo and the title in action bar. You can use getActivity().getActionBar().setTitle("your title"); and getActivity().getActionBar().setLogo(your draw id); 回答2: It is very easy to do .. There's lot's of way to do this task as defined above .. but I will suggest to make use of

Opening/Closing NavDrawer with invalidateOptionsMenu() cause onRestore call on SearchView and onQueryTextChange is called as well

雨燕双飞 提交于 2019-12-04 04:25:16
问题 I have a MainActivity with callbacks implementation of: DrawerListFragment.Callback ItemListFragment.Callbacks SearchView.OnQueryTextListener I have also added an ActionBar SearchView, and finally implemented OnQueryTextListener to change the listView of the listFragment at each kb type, but this works! Also, clicking an item on navDrawer generates a new/replace FragmentList transaction for the new type of itemsList. Now the problem. The ActionBar SearchView actually filters the current

ListView inside scroll view magic

旧时模样 提交于 2019-12-04 04:24:43
问题 For my app I want to enable a thing looking somehow like this: <ScrollView> <LinearLayout orientation="vertical"> <FrameLayout layout_height="48dp"> Anything I want here... </FrameLayout> <ListView> It's size will be set to screen height anyway </ListView> </LinearLayout> </ScrollView> And I want to do so, that when user touches the screen to scroll, at first only scrollview scrolls, and then, when it reaches one of its edges the scroll event goes to listview and it begans scrolling. How can

Dynamic control of action/menu items in ActionBar

风流意气都作罢 提交于 2019-12-04 04:08:33
Is there a way to dynamically disable , hide, add/remove menu items in ActionBar ? For example, an action is disabled until user fills a valid phone number in an activity. I didn't find any useful methods in ActionBar API, the only way seems to be using a custom View in ActionBar. To tell ActionBar to refresh its menu items: invalidateOptionsMenu() then to enable/disable Menu Items: @Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem item= menu.findItem(R.id.men_1); //depending on your conditions, either enable/disable item.setEnabled(false); super.onPrepareOptionsMenu(menu);

Up navigation and saved instance data

北慕城南 提交于 2019-12-04 03:43:08
An app has 2 activities, A and B. A has instance data that is saved @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt("foo", 0); } and A has int bar; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ... if (savedInstanceState != null) { bar = savedInstanceState.getInt("foo"); } else { bar = -1; } } to restore the data. Activity B has the actionbar enabled and @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getActionBar()

How do I set the parent activity of an activity at runtime?

南笙酒味 提交于 2019-12-04 03:42:44
问题 I have an arbitrary number of hierarchically nested views/activities. The action bar should show the Up navigation button to navigate to a higher level in any view. For this, the google documentation says I have to set the parent activity with a tag in the activity's xml definition. However, I'm creating my activities dynamically and a child element can be of the same activity as it's parent. So how do I set the parent activity to the actual parent instance at runtime? 回答1: It sounds like you

Replace the action bar's title with a spinner (drop down)

雨燕双飞 提交于 2019-12-04 03:42:25
I am trying to display a spinner in the same position where the action bar's default title appear. I followed the instruction of the similar SO case here , so I managed to eliminate the title but still the spinner's position is not aligned to the left, as you can see from this screen-shot Here are the main definitions of my application to reproduce this case: AndroidMenifest.xml: <application android:label="app" android:icon="@drawable/ic_launcher" android:theme="@style/Theme.AppCompat" > ... <activity android:name="gm.activities.ViewAllActivity"> <meta-data android:name="android.support

actionbar setnavigationmode deprecated

不羁的心 提交于 2019-12-04 03:38:39
问题 Hi I'm making an app in which I plan on showing floor & category wise listing of stores inside a mall. Below snap show an activity showing floor wise listing of stores I was thinking of adding a spinner in the ActionBar showing "by Floor" and "by Category" as options. Clicking on "by Category" would arrange the stores according to the category in which they belong. After googling a bit I found getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); would be apt but now I see that

ActionBar SearchView not fully expanding in landscape mode

六月ゝ 毕业季﹏ 提交于 2019-12-04 03:24:40
When using the action bar search interface, the widget expands to occupy the full width of the screen in portrait mode, but stops short in landscape mode. Is there a way to set the expansion layout params on the SearchView to fully fill the action bar when the user is typing a search? See image: Note: I'm not currently using ActionBar Sherlock Edit: Here's what I did to get it to extend the full width. searchView.setOnSearchClickListener(new OnClickListener() { private boolean extended = false; @Override public void onClick(View v) { if (!extended) { extended = true; LayoutParams lp = v

ActionBar with icon and text in portrait mode

牧云@^-^@ 提交于 2019-12-04 03:07:33
问题 I can't seem to get an image and text to work in portrait mode on menu items in the action bar no matter what I try. I even tried to force android portrait orientation My XML: <item android:id="@+id/menu_save" android:icon="@drawable/content" android:orderInCategory="100" android:title="New Group" android:showAsAction="withText|always" /> Has anyone figured this out? 回答1: From the config.xml file of the native ActionBar: values: <bool name="config_allowActionMenuItemTextWithIcon">false</bool>