Android: Expand/collapse animation

I see that this question became popular so I post my actual solution. The main advantage is that you don’t have to know the expanded height to apply the animation and once the view is expanded, it adapts height if content changes. It works great for me. public static void expand(final View v) { int … Read more

SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable

Please follow below steps it work’s for me: Go to your react-native Project then go to android directory Create a file with following name: local.properties Open the file and paste your Android SDK path like below: For windows users: sdk.dir=C:\\Users\\UserName\\AppData\\Local\\Android\\sdk Replace UserName with your pc user name . Also make sure the folder is sdk … Read more

Programmatically obtain the phone number of the Android phone

Code: TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE); String mPhoneNumber = tMgr.getLine1Number(); Required Permission: <uses-permission android:name=”android.permission.READ_PHONE_STATE”/> Caveats: According to the highly upvoted comments, there are a few caveats to be aware of. This can return null or “” or even “???????”, and it can return a stale phone number that is no longer valid. If you want something … Read more

Difference between “@id/” and “@+id/” in Android

you refer to Android resources , which are already defined in Android system, with @android:id/.. while to access resources that you have defined/created in your project, you use @id/.. More Info As per your clarifications in the chat, you said you have a problem like this : If we use android:id=”@id/layout_item_id” it doesn’t work. Instead … Read more

How to change an Android app’s name?

Yes you can. By changing the android:label field in your application node in AndroidManifest.xml. Note: If you have added a Splash Screen and added <activity android:name=”.SplashActivity” android:label=”@string/title_activity_splash_screen” android:theme=”@style/AppTheme”> <intent-filter> <action android:name=”android.intent.action.MAIN” /> <action android:name=”android.intent.action.VIEW” /> <category android:name=”android.intent.category.LAUNCHER” /> </intent-filter> </activity> to your Splash Screen, then the Launcher Icon name will be changed to the name … Read more

Why is my Button text forced to ALL CAPS on Lollipop?

I don’t have idea why it is happening but there 3 trivial attempts to make: Use android:textAllCaps=”false” in your layout-v21 Programmatically change the transformation method of the button. mButton.setTransformationMethod(null); Check your style for Allcaps Note: public void setAllCaps(boolean allCaps), android:textAllCaps are available from API version 14.

Declaring a custom android UI element using XML

The Android Developer Guide has a section called Building Custom Components. Unfortunately, the discussion of XML attributes only covers declaring the control inside the layout file and not actually handling the values inside the class initialisation. The steps are as follows: 1. Declare attributes in values\attrs.xml <?xml version=”1.0″ encoding=”utf-8″?> <resources> <declare-styleable name=”MyCustomView”> <attr name=”android:text”/> <attr … Read more

How to display Toast in Android?

In order to display Toast in your application, try this: Toast.makeText(getActivity(), (String)data.result, Toast.LENGTH_LONG).show(); Another example: Toast.makeText(getActivity(), “This is my Toast message!”, Toast.LENGTH_LONG).show(); We can define two constants for duration: int LENGTH_LONG Show the view or text notification for a long period of time. int LENGTH_SHORT Show the view or text notification for a short period … Read more

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