android-actionbar

Why does my app crash invoking “setupActionBarWithNavController(navController, appBarConfiguration)”

喜欢而已 提交于 2020-05-30 19:11:47
问题 I am getting an error message in the LogCat window of Android Studio; Process: com.riverstonetech.gositeuk, PID: 27370 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.riverstonetech.gositeuk/com.riverstonetech.gositeuk.CountriesActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.appcompat.app.ActionBar.setTitle(java.lang.CharSequence)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread

how can i do a rounded toolbar/actionbar in android studio with code like this in the image? [closed]

大兔子大兔子 提交于 2020-05-30 07:00:01
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 months ago . I'm trying to do this, with code and not with background image 回答1: Define xml file like this (this is how i rounded my botton) put the xml file in drawable folder <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android

How to hide menu item in android action bar?

旧城冷巷雨未停 提交于 2020-05-11 07:42:27
问题 My goal is to hide one of the menu items in the action bar and show another after clicking on menu item. In my application, i am using Toolbar . I have already looked for many other questions and did not find what I needed. Any help will be appreciated. I tried code below, but this crashes app after click. public boolean onOptionsItemSelected(MenuItem item) { final SwipeRefreshLayout mySwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swiperefresh); switch (item.getItemId()) { case

How to hide menu item in android action bar?

旧城冷巷雨未停 提交于 2020-05-11 07:39:08
问题 My goal is to hide one of the menu items in the action bar and show another after clicking on menu item. In my application, i am using Toolbar . I have already looked for many other questions and did not find what I needed. Any help will be appreciated. I tried code below, but this crashes app after click. public boolean onOptionsItemSelected(MenuItem item) { final SwipeRefreshLayout mySwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swiperefresh); switch (item.getItemId()) { case

findViewById for MenuItem returns null

|▌冷眼眸甩不掉的悲伤 提交于 2020-05-11 03:46:07
问题 This is my xml file for the ActionBar menu. <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/fav_button" android:title="Favourite" android:icon="@drawable/unstar" android:showAsAction="always|withText" /> </menu> In my onCreate function, after calling setContentView . I do favButton = (MenuItem) this.findViewById(R.id.fav_button); But this returns null. But returns the proper object on the onOptionsItemSelected

add an actionbar for each fragment

吃可爱长大的小学妹 提交于 2020-04-16 02:41:25
问题 Suppose I have 4 fragments that I put in mainActivity, I want to create different actionbar different in each frgament. When I press fragment 1 then the actionBar appears fragment 1, when I press the two fragment that appears actoinbar belonging to fragment 2 01-02 20:12:33.700 15035-15035/src.go_letskerja E/AndroidRuntime: FATAL EXCEPTION: main Process: src.go_letskerja, PID: 15035 java.lang.NullPointerException at src.go_letskerja.Fragment.OtherFragment.onCreateView(OtherFragment.java:26)

How to put tabs on the actionBar, same level with Up button and menus

无人久伴 提交于 2020-03-23 17:53:56
问题 My application has two tabs and I want to put it right on the ActionBar like this However these tabs are always separated in lower level compare to Up button and menus as below: I do not use: android:uiOptions="splitActionBarWhenNarrow" How can I achieve my actionbar like the first image? Thank you very much for any suggestion! 回答1: I would suggest to make a custom layout for your action bar that will have two buttons or Imageviews that look like tabs and switch between fragments onClick().

How to put tabs on the actionBar, same level with Up button and menus

若如初见. 提交于 2020-03-23 17:53:40
问题 My application has two tabs and I want to put it right on the ActionBar like this However these tabs are always separated in lower level compare to Up button and menus as below: I do not use: android:uiOptions="splitActionBarWhenNarrow" How can I achieve my actionbar like the first image? Thank you very much for any suggestion! 回答1: I would suggest to make a custom layout for your action bar that will have two buttons or Imageviews that look like tabs and switch between fragments onClick().

How to remove default android action bar after setting custom action bar view

旧巷老猫 提交于 2020-03-05 15:12:13
问题 Hi all I have one problem I am trying to move action bar app icon,title,menu or... from left to right and I am using SherlockActionBar with setCustomView see codes my activity private void BiftorSetUpActionBar() { // TODO Auto-generated method stub getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); View actionbarview = getLayoutInflater().inflate(R.layout.biftor_action_bar, null); View app_actionbar_bg =(View) actionbarview.findViewById(R.id.app_actionbar_bg); app

How to remove default android action bar after setting custom action bar view

橙三吉。 提交于 2020-03-05 15:12:08
问题 Hi all I have one problem I am trying to move action bar app icon,title,menu or... from left to right and I am using SherlockActionBar with setCustomView see codes my activity private void BiftorSetUpActionBar() { // TODO Auto-generated method stub getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); View actionbarview = getLayoutInflater().inflate(R.layout.biftor_action_bar, null); View app_actionbar_bg =(View) actionbarview.findViewById(R.id.app_actionbar_bg); app