Android changing Floating Action Button color

As described in the documentation, by default it takes the color set in styles.xml attribute colorAccent. The background color of this view defaults to the your theme’s colorAccent. If you wish to change this at runtime then you can do so via setBackgroundTintList(ColorStateList). If you wish to change the color in XML with attribute app:backgroundTint … Read more

Is it possible to use Java 8 for Android development?

UPDATE 2017/11/04 – Android Studio 3.0 now has native support for Java 8. gradle-retrolambda is now no longer needed. See https://developer.android.com/studio/write/java8-support.html The above link also includes migration instructions if you are using gradle-retrolambda. Original answer below: Android does not support Java 8. It only supports up to Java 7 (if you have kitkat) and still … Read more

Why `PagerAdapter::notifyDataSetChanged` is not updating the View?

There are several ways to achieve this. The first option is easier, but bit more inefficient. Override getItemPosition in your PagerAdapter like this: public int getItemPosition(Object object) { return POSITION_NONE; } This way, when you call notifyDataSetChanged(), the view pager will remove all views and reload them all. As so the reload effect is obtained. … Read more

How to change the color of header bar and address bar in newest Chrome version on Lollipop?

Found the solution after some searching. You need to add a <meta> tag in your <head> containing name=”theme-color”, with your HEX code as the content value. For example: <meta name=”theme-color” content=”#999999″ /> Update: If the android device has native dark-mode enabled, then this meta tag is ignored. Chrome for Android does not use the color … Read more

Difference between getContext() , getApplicationContext() , getBaseContext() and “this”

View.getContext(): Returns the context the view is currently running in. Usually the currently active Activity. Activity.getApplicationContext(): Returns the context for the entire application (the process all the Activities are running inside of). Use this instead of the current Activity context if you need a context tied to the lifecycle of the entire application, not just … Read more

Set icon for Android application

If you intend on your application being available on a large range of devices, you should place your application icon into the different res/drawable… folders provided. In each of these folders, you should include a 48dp sized icon: drawable-ldpi (120 dpi, Low density screen) – 36px x 36px drawable-mdpi (160 dpi, Medium density screen) – … Read more

Android: How do I get string from resources using its name?

The link you are referring to seems to work with strings generated at runtime. The strings from strings.xml are not created at runtime. You can get them via String mystring = getResources().getString(R.string.mystring); getResources() is a method of the Context class. If you are inside a Activity or a Service (which extend Context) you can use … Read more

Retrieving Android API version programmatically

As described in the Android documentation, the SDK level (integer) the phone is running is available in: android.os.Build.VERSION.SDK_INT The class corresponding to this int is in the android.os.Build.VERSION_CODES class. Code example: if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP){ // Do something for lollipop and above versions } else{ // do something for phones running an SDK before lollipop … Read more

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