Custom Translucent Android ActionBar

If you want your activity to be fullscreen but still show an actionbar, but with an alpha you have to request overlaymode for the actionbar in onCreate() of your activity: getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); //getWindow().requestFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY); << Use this for API 7+ (v7 support library) Then after you call setContentView(..) (since setContentView(..) also initializes the actionbar next to setting … Read more

Fragment already added IllegalStateException

In the end my workaround was to execute remove() of the previous fragment and add() the new one. Although that’s what replace() method was meant to do. But I am still guessing why replace() method didn’t work properly in this case. It is really weird and I want to discard that it is because I … Read more

Android replace the current fragment with another fragment

Then provided your button is showing and the click event is being fired you can call the following in your click event: final FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.details, new NewFragmentToReplace(), “NewFragmentTag”); ft.commit(); and if you want to go back to the DetailsFragment on clicking back ensure you add the above transaction to the back stack, … Read more

Is it possible to display icons in a PopupMenu?

Contribution to the solution provided by Gaelan Bolger. Use this code if you get a “IllegalAccessException: access to field not allowed”. PopupMenu popup = new PopupMenu(mContext, view); try { Field[] fields = popup.getClass().getDeclaredFields(); for (Field field : fields) { if (“mPopup”.equals(field.getName())) { field.setAccessible(true); Object menuPopupHelper = field.get(popup); Class<?> classPopupHelper = Class.forName(menuPopupHelper .getClass().getName()); Method setForceIcons = … Read more

Is there a way to get references for all currently active fragments in an Activity?

Looks like the API currently misses a method like “getFragments”. However using the event “onAttachFragment” of class Activity it should be quite easy to do what you want. I would do something like: List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>(); @Override public void onAttachFragment (Fragment fragment) { fragList.add(new WeakReference(fragment)); } public List<Fragment> getActiveFragments() { ArrayList<Fragment> ret = … Read more

How to dismiss keyboard in Android SearchView?

I was trying to do something similar. I needed to launch the SearchActivity from another Activity and have the search term appear on the opened search field when it loaded. I tried all the approaches above but finally (similar to Ridcully’s answer above) I set a variable to SearchView in onCreateOptionsMenu() and then in onQueryTextSubmit() … Read more

How to use Holo.Light theme, and fall back to ‘Light’ on pre-honeycomb devices?

You have to create a custom theme and save it in some directories to finally set this theme as the default one for the app First, in values add a themes.xml like this: <?xml version=”1.0″ encoding=”utf-8″?> <resources> <style name=”MyAppTheme” parent=”@android:style/Theme.Light.NoTitleBar”> <!– Any customizations for your app running on pre-3.0 devices here –> </style> </resources> Then, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)