android-actionbar

Android fragment lifecycle issue with actionbar

帅比萌擦擦* 提交于 2019-12-12 05:15:55
问题 I want to realize the navigation of the fragments using the following code: public abstract class BaseFragment extends Fragment { private static String TAG = "BaseFragment"; private BaseFragmentActions baseFragmentActions; @Override public void onAttach(Context context) { super.onAttach(context); Activity activity = null; if (context instanceof Activity){ activity = (Activity) context; } Log.i(TAG, "onAttach = "); try { baseFragmentActions = (BaseFragmentActions)activity; } catch

Grab TabText in Fragment

杀马特。学长 韩版系。学妹 提交于 2019-12-12 05:04:32
问题 I have an ActionBar that contains 11 tabs and 1 fragment. I also have a ViewPager to display the fragment(s). When a tab is clicked it creates the same fragment. The tabs display dates so they change everyday. What I need is to send the text of the tab (ie. .getTabText()) to the fragment, this will change the content of the fragment. I am having so much trouble trying to figure out how to do this. Here is all my code: public class MainActivity extends FragmentActivity implements ActionBar

cannot combine custom titles with other title features

柔情痞子 提交于 2019-12-12 04:56:09
问题 I have created a custom title bar for one of my screen and trying to use the same concept in other ,but getting android.util.AndroidRuntimeException: You cannot combine custom titles with other title features . Requirement: styles.xml: <?xml version="1.0" encoding="utf-8"?> <resources> <style name="titleBarHeading" parent="@android:style/TextAppearance"> <item name="android:textSize">17sp</item> <item name="android:textStyle">bold</item> <item name="android:textColor">#444444</item> </style>

how display logo on action bar

為{幸葍}努か 提交于 2019-12-12 04:55:37
问题 i want to show logo on my action bar activity and i used below code in manifest: <activity android:name=".CompanyActivity" android:icon="@drawable/ic_launcher" android:logo="@drawable/ic_launcher" android:label="@string/title" android:screenOrientation="portrait" android:theme="@style/Theme.AppCompat.Light.DarkActionBar" > </activity> and also use both below codes in java, in onCreate method of activity: getSupportActionBar().setIcon(R.drawable.ic_launcher); and ActionBar ab =

Changing visibility of menu items in fragment

亡梦爱人 提交于 2019-12-12 04:45:43
问题 I'm trying to hide some menu items when a fragment is changed, but seems that this is not working. Here is what im doing: Defining the menu and menu items: @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu items for use in the action bar MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.actionbar_sharecall, menu); actionMenu = menu; MenuItem searchItem = menu.findItem(R.id.action_searchmenuitem); MenuItem item = menu.findItem(R.id.action_menushare)

Updating Action Bar Menu Item due to AsyncTask result without delay

强颜欢笑 提交于 2019-12-12 04:39:50
问题 I developed an Application which offers a detail view Activity (An activity which is called when clicking on a list item to display further information). This details Activity shall display a "favorite" start in the Action Bar (it is yellow if the item is a favorite, transparent if not - for this purpose I have to different image resources) If i click the menu item, the item is added / removed form the user's favorites: @Override public boolean onOptionsItemSelected(MenuItem item) { if (item

Remove the navigation drawer icon and use the app icon to open

耗尽温柔 提交于 2019-12-12 04:39:08
问题 I want to remove the small navigation drawer icon and open the left panel on actionbar icon click. How can I do this? Actually I'm creating an Actionbar like Pinterest's 回答1: If you want to get rid of the DrawerLayout indicator don't use the ActionBarDrawerToggle . To toggle the DrawerLayout when you select the ActionBar home affordance call DrawerLayout.openDrawer and DrawerLayout.closeDrawer depending on the current state. switch (item.getItemId()) { case android.R.id.home: if

Android: Add two TextViews to Actionbar Spinner

佐手、 提交于 2019-12-12 04:35:01
问题 Is there anyway to add two text views or strings inside of the Actionbar Spinner? Similar to how the Android GMAIL app does it. 回答1: You could use a custom ArrayAdapter: public class spinnerAdapter extends ArrayAdapter { private LayoutInflater inflater; public spinnerAdapter(Context context, int textViewResourceId) { super(context, textViewResourceId); inflater = LayoutInflater.from(context); } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder

Title for icon in actionbar is not shown

≯℡__Kan透↙ 提交于 2019-12-12 04:14:18
问题 Hi I want to add a icon with title to my actionbar, but only the icon is shown. I created this item: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/menu_save" android:icon="@android:drawable/ic_menu_save" android:title="@string/menu_save" android:showAsAction="ifRoom|withText"/> </menu> Anyone a idea? I also changed ifRoom to always but still the same problem.. 回答1: That occurs in ICS, right? This appears to be

Search-view not working correctly in android toolbar

空扰寡人 提交于 2019-12-12 04:08:52
问题 I am using search view in my Flickr app but when I run, it just display the title of search view not it's search icon and when I click on the title it should display and area to type the search query but nothing happen it treat like a simple toolbar item this is menu xml file <?xml version="1.0" encoding="utf-8"?> <menu xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id