Changing overflow icon in the action bar

You can with a style, but you have to add it to the main Theme declaration. <resources> <!– Base application theme. –> <style name=”Your.Theme” parent=”@android:style/Theme.Holo”> <!– Pointer to Overflow style ***MUST*** go here or it will not work –> <item name=”android:actionOverflowButtonStyle”>@style/OverFlow</item> </style> <!– Styles –> <style name=”OverFlow” parent=”@android:style/Widget.Holo.ActionButton.Overflow”> <item name=”android:src”>@drawable/ic_action_overflow</item> </style> </resources> You also can … Read more

how to turn speaker on/off programmatically in android 4.0

Something like this might work on some devices (I’ve only tested in on an XPeria P): final static int FOR_MEDIA = 1; final static int FORCE_NONE = 0; final static int FORCE_SPEAKER = 1; Class audioSystemClass = Class.forName(“android.media.AudioSystem”); Method setForceUse = audioSystemClass.getMethod(“setForceUse”, int.class, int.class); setForceUse.invoke(null, FOR_MEDIA, FORCE_SPEAKER); // To get back to the default behaviour, … Read more

Difference between android-support-v7-appcompat and android-support-v4

UPDATE There are many changes done into support library since this question was answered. Good thing is, it is very well documented also. So you must read Support Library Documentation for more details and more available support library. Starting with Support Library release 26.0.0 (July 2017), the minimum supported API level across most support libraries … Read more

How can I force the Action Bar to be at the bottom in ICS?

I’ve tried adding the line in the application manifest, as described in the docs, but haven’t got it working thus far. It worked for me in this sample project. Here is the manifest: <?xml version=”1.0″ encoding=”utf-8″?> <manifest package=”com.commonsware.android.actionbarbc” xmlns:android=”http://schemas.android.com/apk/res/android”> <application android:hardwareAccelerated=”true” android:icon=”@drawable/cw” android:label=”@string/app_name”> <activity android:label=”@string/app_name” android:name=”.InflationDemo” android:uiOptions=”splitActionBarWhenNarrow”> <intent-filter> <action android:name=”android.intent.action.MAIN” /> <category android:name=”android.intent.category.LAUNCHER” /> </intent-filter> … Read more

Determine addAction click for Android notifications

It’s because you’re using FLAG_UPDATE_CURRENT with Intents that have the same action From the docs: if the described PendingIntent already exists, then keep it but its replace its extra data with what is in this new Intent. When you specify pendingIntentMaybe and pendingIntentNo, the system uses the PendingIntent created for pendingIntentYes, but it overwrites the … Read more

getView returning null when fragment has been created from an activity

Move your method call to be executed during onCreateView, and use the view you are inflating for reference instead of getView(). See the fragment lifecycle for more information: https://developer.android.com/guide/components/fragments.html#Creating and the documentation of getView() that explains why it returns null before onCreateView(LayoutInflater, ViewGroup, Bundle) returns: getView() Get the root view for the fragment’s layout (the … Read more

Disable keyboard on EditText

Below code is both for API >= 11 and API < 11. Cursor is still available. /** * Disable soft keyboard from appearing, use in conjunction with android:windowSoftInputMode=”stateAlwaysHidden|adjustNothing” * @param editText */ public static void disableSoftInputFromAppearing(EditText editText) { if (Build.VERSION.SDK_INT >= 11) { editText.setRawInputType(InputType.TYPE_CLASS_TEXT); editText.setTextIsSelectable(true); } else { editText.setRawInputType(InputType.TYPE_NULL); editText.setFocusable(true); } }

tech