Posts

How to create clickable links in a textView on Android ?

Image
• Add the following code to res/layout/ activity_main.xml. <? xml version = "1.0" encoding = "utf-8" ?> <RelativeLayout xmlns:android = "http://schemas.android.com/apk/res/android"     xmlns:tools = "http://schemas.android.com/tools"     android:layout_width = "match_parent"     android:layout_height = "match_parent"     tools:context = ".MainActivity" >     <TextView       android:id = "@+id/textViewLink"       android:layout_width = "wrap_content"       android:layout_height = "wrap_content"       android:layout_centerInParent = "true"       android:textSize = "24sp"       android:textStyle = "bold"       android:gravity = "center"       android:text = "@string/messageWithLink" /> </RelativeLayout> •  Open res/values/ strings.xml and add the following code: <resources>     <string

How to change app language when user selects language in Android ?

Image
• Add the following code to res/layout/ activity_main.xml. <RelativeLayout     xmlns:android = "http://schemas.android.com/apk/res/android"     xmlns:tools = "http://schemas.android.com/tools"     android:id = "@+id/rl"     android:layout_width = "match_parent"     android:layout_height = "match_parent"     android:padding = "10dp"     tools:context = ".MainActivity" >     <Spinner       android:id = "@+id/spinner"       android:layout_width = "wrap_content"       android:layout_height = "wrap_content"       android:layout_centerInParent = "true" />     <TextView       android:id = "@+id/string"       android:layout_width = "wrap_content"       android:layout_height = "wrap_content"       android:text = "@string/thank_you"       android:textSize = "24sp"       android:layout_centerInParent =

How to count number of characters in EditText while typing in android ?

Image
•      Add the following code to res/layout/ activity_main.xml. <? xml version = "1.0" encoding = "utf-8" ?> <RelativeLayout     xmlns:android = "http://schemas.android.com/apk/res/android"     xmlns:tools = "http://schemas.android.com/tools"     android:layout_width = "match_parent"     android:layout_height = "match_parent"     android:padding = "4dp"     tools:context = ".MainActivity" >     <EditText       android:id = "@+id/editText"       android:layout_width = "wrap_content"       android:layout_height = "wrap_content"       android:layout_centerInParent = "true"       android:ems = "10"       android:hint = "EditText" />     <TextView       android:id = "@+id/textView"       android:layout_width = "wrap_content"       android:layout_height = "wrap_content"       andr