android-actionbar

getActionBar() works fine on devices/simulator but returns null in testcases

老子叫甜甜 提交于 2019-12-13 00:55:03
问题 Application supports minSdk=14 and have ActionBar on every Activity . Application works fine since a long time and shows ActionBar on every Activity . Now I am writing Android JUnit Testcases but it gives NullPointException on line getActionBar().setDisplayHomeAsUpEnabled(true); The bottom line is getActionBar() works on devices but returns null during test cases. If I remove the line then testcases are fine. Here's how activity looks like. protected void onCreate(Bundle savedInstanceState) {

Change Color of Actionbar in Android

痴心易碎 提交于 2019-12-13 00:44:25
问题 I am trying to change the background color of actionbar in my App but this is showing different on my app. Instead of coloring the actionbar the whole activity is color. I am not sure why this is happening? I just want the main actionbar and settings actionbar colored. Please check the screenshot. Main Activity Map: Preference Settings: I also have transparent Actionbar with UP Navigation enabled for all my sub activities other than the main activity and preference settings activity. I am not

Android app closes when back button pressed

南楼画角 提交于 2019-12-13 00:14:08
问题 I have the following activity which launches a fragment when the tab is selected: public class MainActivity extends Activity implements TabListener { Fragment f = null; ..... public void onTabSelected(Tab tab, FragmentTransaction ft) { ..... if (tab.getPosition() == 0) { if (initalSync == true) { progress1.setVisibility(TRIM_MEMORY_UI_HIDDEN); } f = new EventFragment(); Bundle data = new Bundle(); data.putInt("idx", tab.getPosition()); f.setArguments(data); } if (tab.getPosition() == 1) {

Add ActionBar Items with a fade animation

萝らか妹 提交于 2019-12-12 23:07:54
问题 I have a ViewPager where one of its belonging fragments has its own ActionBar item, so that when you slide to that page the item comes forth in the ActionBar, slide to another page the item goes away. I would like this to happen with a fade-in/fade-out animation - but don't know how. I've tried the following. But it gives me a NullPointerExecption on itemView.startAnimation(fade_in); @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu

Action bar is hidden and that shown instantly after that

自作多情 提交于 2019-12-12 22:13:46
问题 I'm trying to toggle show/hide action bar on user click on activity, so I've implemented this functionality like this in activity: @Override public boolean dispatchTouchEvent(MotionEvent ev) { Log.d("ACTION BAR", "triggered"); super.dispatchTouchEvent(ev); ActionBar actionBar = getSupportActionBar(); actionBar.hide(); if (actionBar.isShowing()) { actionBar.hide(); } else { actionBar.show(); } return true; } However, the problem is that when clicked on activity, the action bar gets hidden but

Styling tabBar-indicator with ActionBarSherlock

烂漫一生 提交于 2019-12-12 21:31:52
问题 I am currently not able to customize the tab-indicator in my app when using Actionbarsherlock. I am trying to change the default color (blue) to white of the indicator. All other customization works as intended. I am not even able to remove the tab-indicator. Have I missed something in my XML-code or what might be the problem? Also note, my min-SDK is set to 14 in the manifest -file. ALL help is needed so I can manage to find the source of the problem :/ Regards Tabs.java @Override public

SearchView.isFocused always returns false

≯℡__Kan透↙ 提交于 2019-12-12 20:34:01
问题 I'm trying to determine whether a SearchView in the ActionBar is focused. But when I call SearchView.isFocused() I always get false as a result, even when the view is really focused (there is a cursor inside, and the soft keyboard is shown). How can I check, whether a SearchView is focused? 回答1: After some researching, I learned that SearchView.isFocused() always returns false because it's some child of the SearchView who really has the focus, not the SearchView itself. So I use the following

Can't format action bar Title

别说谁变了你拦得住时间么 提交于 2019-12-12 18:27:19
问题 This is probably a really simple question to answer but at the moment I can't sort it. I have my action set up as follows: // get action bar ActionBar actionBar = getSupportActionBar(); // set up the action bar layout final ViewGroup actionBarLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.actionbar_layout,null); // apply layout actionBar.setCustomView(actionBarLayout); I have tried to set up the action bar title as follows: // setting action bar title actionBar.setTitle

Managing Action Bar titles when using fragments and the backstack

社会主义新天地 提交于 2019-12-12 15:40:59
问题 My app has an activity which uses the FragmentManager to push and pop fragments onto the backstack. However, when the backstack has 2 fragments and the last fragment is popped, I do not how to detect this to set the title of the Action Bar appropriately. I was hoping there was some method on a fragment I could override to determine when it becomes visible, but none of those suggested e.g. uservisiblehint, onHiddenChanged, etc. are called. How can I either: • determine when a fragment becomes

ActionBar tab styles in horizontal view

∥☆過路亽.° 提交于 2019-12-12 14:23:32
问题 When using a phone or a tablet in portrait mode, tabs are shown under the ActionBar that constains the logo and menu items. On tablets in horizontal mode they are shown inline with the logo and menu items. In this configuration the underscore under the seleced tab is lost. What style controls this? In portrait mode I want to use a different selected style than in landscape mode when tabs are shown inline with the logo and menu. My theme has it's parent set to Theme.AppCompat.Light . Under it