How to prevent a dialog from closing when a button is clicked

EDIT: This only works on API 8+ as noted by some of the comments. This is a late answer, but you can add an onShowListener to the AlertDialog where you can then override the onClickListener of the button. final AlertDialog dialog = new AlertDialog.Builder(context) .setView(v) .setTitle(R.string.my_title) .setPositiveButton(android.R.string.ok, null) //Set to null. We override the onclick … Read more

All com.android.support libraries must use the exact same version specification

You can solve this with one of the following solutions: Update: As of Android studio 3.0, it becomes much easier as it now shows a more helpful hint, so we only need to follow this hint. for example: All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). … Read more

Error retrieving parent for item: No resource found that matches the given name after upgrading to AppCompat v23

Your compile SDK version must match the support library’s major version. Since you are using version 23 of the support library, you need to compile against version 23 of the Android SDK. Alternatively you can continue compiling against version 22 of the Android SDK by switching to the latest support library v22.

How to put a border around an Android TextView?

You can set a shape drawable (a rectangle) as background for the view. <TextView android:text=”Some text” android:background=”@drawable/back”/> And rectangle drawable back.xml (put into res/drawable folder): <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:shape=”rectangle” > <solid android:color=”@android:color/white” /> <stroke android:width=”1dip” android:color=”#4fa5d5″/> </shape> You can use @android:color/transparent for the solid color to have a transparent background. You can also use padding to … Read more

How do you install an APK file in the Android emulator?

You can simply drag and drop the .apk file of your application to the emulator and it will automatically start installing. Another option: Windows: Execute the emulator (SDK Manager.exe->Tools->Manage AVDs…->New then Start) Start the console (Windows XP), Run -> type cmd, and move to the platform-tools folder of SDK directory. Paste the APK file in … Read more

How to determine when Fragment becomes visible in ViewPager

How to determine when Fragment becomes visible in ViewPager You can do the following by overriding setUserVisibleHint in your Fragment: public class MyFragment extends Fragment { @Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); if (isVisibleToUser) { } else { } } }

How to change fontFamily of TextView in Android

From android 4.1 / 4.2 / 5.0, the following Roboto font families are available: android:fontFamily=”sans-serif” // roboto regular android:fontFamily=”sans-serif-light” // roboto light android:fontFamily=”sans-serif-condensed” // roboto condensed android:fontFamily=”sans-serif-black” // roboto black android:fontFamily=”sans-serif-thin” // roboto thin (android 4.2) android:fontFamily=”sans-serif-medium” // roboto medium (android 5.0) in combination with android:textStyle=”normal|bold|italic” this 16 variants are possible: Roboto regular Roboto italic … Read more

Service vs IntentService in the Android platform

Tejas Lagvankar wrote a nice post about this subject. Below are some key differences between Service and IntentService. When to use? The Service can be used in tasks with no UI, but shouldn’t be too long. If you need to perform long tasks, you must use threads within Service. The IntentService can be used in … Read more

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