Android: How to change the colour of menu icons
On phone, will improve later. This should work:
Technical answers from my Stack Overflow history, with source links and licenses.
Showing 30 of 268 answers
Exported May 9, 2026
On phone, will improve later. This should work:
I just decompiled KNOX Status . It looks like all the app is doing is getting the system property ro.boot.warranty_bit . I'm not sure if this still works and I don't have a Samsung at the moment to test. In terminal...
You can download the old ActionBar (Holo styled) icon pack that was on the official Android developer website here . This github repo also has the Holo styled icons.
You surpassed the 65k method limit in DEX. Earlier versions of Android build system report the error as follows: Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536 You can...
RootTools isn't the greatest. Personally, I suggest going with libsuperuser . There are plenty of reasons why your file isn't being deleting. If you look at RootTools, it doesn't add quotes around the path. So, if your...
As commented previously, android.os.FileUtils has changed and the solution posted by Ashraf no longer works. The following method should work on all versions of Android (although it does use reflection and if a...
Your code is compiled into a dex file inside your APK (classes.dex) and all resources are saved as a tree at the base of your APK. Because of this, ResourceBundle.getBundle(String) or...
This worked for me in a simple example I wrote: The code you are using should work for any MenuItem in the overflow, but does not work for MenuItem s that are always showing on the ActionBar .
The outer try-block will still catch exceptions from the inner try-block. The inner try-block is there to make sure DaoUtils.closeStatement(callStmt); is invoked.
You currently have two Toolbar layouts in your Activity. You need to set the Toolbar using setSuppotActionBar(Toolbar) . Example:
If I understand correctly, you want the output to be like the second JSON array in your question. Changing where you loop should do the trick: I tested with the input you have. Here is the formatted JSON output:
Are you sure you are using the same jar in both projects? Android's org.json.JSONObject.toString(String) is different: JSON.toString(Object) : In your case this would not throw an exception on Android.
Change the parameters of your AsyncTask to <Integer[], Void, String[]>
You should not be loading a WebView in a background thread; it needs to be loaded on the UI thread. I would add a listener to your WebView and when the URL is finished loading you can add your button.
In your RelativeLayout set android:clickable="true" . Or, a better approach would be to set an OnItemClickListener on your ListView .
Alex has a great answer. WARNING : Ugly code ahead I was able to get the signature in adb shell as root with the following code: indented:
You will need root access to do this from an app because ADB can access /system/bin/service but your app cannot (see GID of app and ADB). You should also check out third party libraries for handling su commands:...
You can use SystemBarTint or simply copy the static factory method below and call it in onCreate(Bundle savedInstanceState) in your Activity :
You can set the EdgeEffect color using reflection. The following will work from API 14+:
Here is a View.OnTouchListener that you can use to see if MotionEvent.ACTION_UP was sent while the user had his/her finger outside of the view:
Here is a method for getting a random color: Benefits: Get the integer representation which can be used with java.awt.Color or android.graphics.Color Keep a static reference to Random .
final It is used in the following three cases: If the final keyword is attached to a variable then the variable becomes constant i.e. its value cannot be changed in the program. If a method is marked as final then the...
You can get a random number between 6 and 10 like this: Here is an example to play a sound every 6 to 10 seconds: Just call playMySound(); in onCreate(Bundle) and toggle mKeepPlaying when you want to stop.
To answer your question, it is simply impossible to make your APK fully secure. XML files are easily parsed without apktool . I asked Ben Gruver/JesusFreke (the guy who developed smali) and he said it is impossible to...
The code should be working fine as long as dt and days are correct. This gave me 12-18-2014:
Just because the app name is "2048" does not mean it is used in the package name. However, I looked up the most popular Google Play game and it does have 2048 in the package name. You could use grep to get the package....
Make a separate integer-array in XML for the ids: Get the int array in code: Using the position get the correct id from the array in onItemSelected :
Saving all the images in R.drawable is not the best idea. It would be better to save specific images instead of all of them. However, here is how you could save all the images as specified in R.drawable :
You can use a case statement to get the density. This worked for me: Updated code using -le (less than or equal to): Output on my device:
If a ZipException or IOException is being thrown when initializing ZipFile then you should test the integrity of the ZIP. You may also want to make sure you have read/write access. If you are unzipping this file on...