Found 1626 Articles for Android

How to use AutoCompleteTextView in Android App?

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

239 Views

This example demonstrate about How to use AutoCompleteTextView in Android App.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.java     Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.sample ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; import android.support.v7.widget.AppCompatAutoCompleteTextView ; import android.widget.ArrayAdapter ; public class MainActivity extends AppCompatActivity {    private String[] fruits = { "Apple" , "Banana" , "Cherry" , "Date" , "Grape" , "Kiwi" , "Mango" , "Pear" } ;   ... Read More

How to set margins in an Android LinearLayout programmatically?

Chandu yadav
Updated on 30-Jul-2019 22:30:26

5K+ Views

This example demonstrate about How to set margins in an Android LinearLayout programmatically.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.java Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.sample ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; import android.widget.Button ; import android.widget.LinearLayout ; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate (Bundle savedInstanceState) {       super .onCreate(savedInstanceState) ;       setContentView(R.layout. activity_main ) ;       ... Read More

How do I get the resource id of an image if I know its name in Android?

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

3K+ Views

This example demonstrate about How do I get the resource id of an image if I know its name in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.java         Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.sample ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; import android.util.Log ; import android.widget.TextView ; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate (Bundle savedInstanceState) {       ... Read More

How to add manifest permission to an application in Android?

George John
Updated on 30-Jul-2019 22:30:26

631 Views

This example demonstrate about How to add manifest permission to an application in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.java Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.sample ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate (Bundle savedInstanceState) {       super .onCreate(savedInstanceState) ;       setContentView(R.layout. activity_main ) ;    } }Step 4 − Add the following ... Read More

How to make an Android device vibrate programmatically?

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

738 Views

This example demonstrate about How to make an Android device vibrate programmatically.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.java     Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.sample ; import android.content.Context ; import android.os.Build ; import android.os.Bundle ; import android.os.VibrationEffect ; import android.os.Vibrator ; import android.support.v7.app.AppCompatActivity ; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate (Bundle savedInstanceState) {       super .onCreate(savedInstanceState) ;     ... Read More

How can I define underlined text in an Android layout xml file?

Chandu yadav
Updated on 30-Jul-2019 22:30:26

2K+ Views

This example demonstrate about How can I define underlined text in an Android layout xml file.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.java     Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.sample ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; import android.text.SpannableString ; import android.text.style.UnderlineSpan ; import android.widget.TextView ; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate (Bundle savedInstanceState) {       super .onCreate(savedInstanceState) ;   ... Read More

How to align views at the bottom of the screen in Android?

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

6K+ Views

This example demonstrate about How to align views at the bottom of the screen in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.java     Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.sample ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate (Bundle savedInstanceState) {       super .onCreate(savedInstanceState) ;       setContentView(R.layout. activity_main ) ;    } }Step 4 − Add the following code to androidManifest.xml                       ... Read More

How to define a MIN and MAX value for EditText in Android?

Chandu yadav
Updated on 30-Jul-2019 22:30:26

3K+ Views

This example demonstrate about How to define a MIN and MAX value for EditText in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.java     Step 3 − Add the following code to src/MinMaxFilter.javapackage app.tutorialspoint.com.sample ; import android.text.InputFilter ; import android.text.Spanned ; public class MinMaxFilter implements InputFilter {    private int mIntMin , mIntMax ;    public MinMaxFilter ( int minValue , int maxValue) {       this . mIntMin = minValue ... Read More

How can I validate EditText input in Android?

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

1K+ Views

This example demonstrate about How can I validate EditText input in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.java     Step 3 − Add the following code to src/ValidateFilter.javapackage app.tutorialspoint.com.sample ; import android.text.InputFilter ; import android.text.Spanned ; import android.util.Log ; import java.util.regex.Matcher ; import java.util.regex.Pattern ; public class ValidateFilter implements InputFilter {    @Override    public CharSequence filter (CharSequence source , int start , int end , Spanned dest ,    int ... Read More

How to check if Location Services are enabled in Android App?

George John
Updated on 30-Jul-2019 22:30:26

2K+ Views

This example demonstrate about How to check if Location Services are enabled in Android App.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.java     Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.sample ; import android.content.Context ; import android.content.DialogInterface ; import android.content.Intent ; import android.location.LocationManager ; import android.os.Bundle ; import android.provider.Settings ; import android.support.v7.app.AlertDialog ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; import android.widget.Button ; import android.widget.TextView ; public class MainActivity extends AppCompatActivity ... Read More

Advertisements