How can I get color-int from color resource?

You can use: getResources().getColor(R.color.idname); Check here on how to define custom colors: http://sree.cc/google/android/defining-custom-colors-using-xml-in-android EDIT(1): Since getColor(int id) is deprecated now, this must be used : ContextCompat.getColor(context, R.color.your_color); (added in support library 23) EDIT(2): Below code can be used for both pre and post Marshmallow (API 23) ResourcesCompat.getColor(getResources(), R.color.your_color, null); //without theme ResourcesCompat.getColor(getResources(), R.color.your_color, your_theme); //with … Read more

Can the Android drawable directory contain subdirectories?

No, the resources mechanism doesn’t support subfolders in the drawable directory, so yes – you need to keep that hierarchy flat. The directory layout you showed would result in none of the images being available. From my own experiments it seems that having a subfolder with any items in it, within the res/drawable folder, will … Read more

Is it possible to have placeholders in strings.xml for runtime values?

Formatting and Styling Yes, see the following from String Resources: Formatting and Styling If you need to format your strings using String.format(String, Object…), then you can do so by putting your format arguments in the string resource. For example, with the following resource: <string name=”welcome_messages”>Hello, %1$s! You have %2$d new messages.</string> In this example, the … Read more

getColor(int id) deprecated on Android 6.0 Marshmallow (API 23)

Starting from Android Support Library 23, a new getColor() method has been added to ContextCompat. Its description from the official JavaDoc: Returns a color associated with a particular resource ID Starting in M, the returned color will be styled for the specified Context’s theme. So, just call: ContextCompat.getColor(context, R.color.your_color); You can check the ContextCompat.getColor() source … Read more

Android getResources().getDrawable() deprecated API 22

You have some options to handle this deprecation the right (and future proof) way, depending on which kind of drawable you are loading: A) drawables with theme attributes ContextCompat.getDrawable(getActivity(), R.drawable.name); You’ll obtain a styled Drawable as your Activity theme instructs. This is probably what you need. B) drawables without theme attributes ResourcesCompat.getDrawable(getResources(), R.drawable.name, null); You’ll … Read more

R cannot be resolved – Android error

After tracking down this problem as well, I found this note in the Android documentation: http://source.android.com/source/using-eclipse.html *Note: Eclipse sometimes likes to add an “import android.R” statement at the top of your files that use resources, especially when you ask Eclipse to sort or otherwise manage imports. This will cause your make to break. Look out … Read more

Is there a way to get the source code from an APK file?

Simple way: use online tool https://www.decompiler.com/, upload apk and get source code. Procedure for decoding .apk files, step-by-step method: Step 1: Make a new folder and copy over the .apk file that you want to decode. Now rename the extension of this .apk file to .zip (e.g. rename from filename.apk to filename.zip) and save it. … Read more

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