Found 1631 Articles for Android

How to create EditText with rounded corners in Android?

Azhar
Updated on 03-Jul-2020 07:00:11

8K+ Views

This example demonstrates how to create EditText with rounded corners 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.xml.     Step 3 − Create a drawable resource file and Add the following code to drawable/et_style.xml         Step 4   − Add the following code to src/MainActivity.javapackage com.example.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.EditText; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       ... Read More

How to display custom view in ActionBar in Android?

Azhar
Updated on 03-Jul-2020 07:01:08

601 Views

This example demonstrates how to display custom view in ActionBar 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.xml.     Step 3 − Add the following code to res/layout/custom_action_bar.xml.                                         Step 4 − Add the following code to src/MainActivity.javapackage com.example.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.app.ActionBar; import android.view.View; import ... Read More

How to load and display an image in ImageView on Android App?

Azhar
Updated on 03-Jul-2020 07:01:48

3K+ Views

This example demonstrates how to load and display an image in ImageView on 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.xml.         Step 3 − Add the following code to src/MyAndroidAppActivity.javapackage com.example.sample; import android.support.v7.app.AppCompatActivity; import android.app.Activity; import android.os.Bundle; import android.widget.Button; import android.widget.ImageView; import android.view.View; import android.view.View.OnClickListener; public class MyAndroidAppActivity extends AppCompatActivity {    Button button;    ImageView image;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState); ... Read More

How to display Toast in Android?

Azhar
Updated on 03-Jul-2020 07:10:11

842 Views

This example demonstrates how to display Toast in Android.Step 1 − Create a new project in Android Studio, go to File rArr; New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml     Step 3 − Add the following code to src/MainActivity.javapackage com.example.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       //Displaying Toast with Hello World message       Toast.makeText(getApplicationContext(), "Hello World", Toast.LENGTH_SHORT).show();   ... Read More

How to work with Camera in an Android App?

Azhar
Updated on 03-Jul-2020 06:39:09

304 Views

This example demonstrates how to work with Camera in an 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.xml.                 Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.ImageView; public class MainActivity extends AppCompatActivity {    private static final int CAMERA_REQUEST=1888;    ImageView imageView;    @Override   ... Read More

How to get the device’s IMEI/ESN number programmatically in android?

Azhar
Updated on 03-Jul-2020 06:41:27

3K+ Views

This example demonstrates how do I get the device’s IMEI/ESN number programmatically 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.xml.         Step 3 − Add the following code to src/MainActivity.javaimport android.Manifest; import android.content.Context; import android.content.pm.PackageManager; import android.support.annotation.NonNull; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.telephony.TelephonyManager; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    Button button;    TextView textView;    String IMEINumber;   ... Read More

How to create text file and insert data to that file on Android?

Azhar
Updated on 03-Jul-2020 06:40:02

7K+ Views

This example demonstrates how to create text file and insert data to that file on 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.xml.                       Step 3 − Add the following code to src/MainActivity.javapackage com.example.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import android.app.Activity; import android.view.View; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    EditText ... Read More

How to use InputFilter to limit characters in an editText in Android?

Azhar
Updated on 03-Jul-2020 06:42:29

1K+ Views

This example demonstrates how do I use inputfilter to limit characters in an 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.xml.     Step 3 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.InputFilter; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    EditText editText;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       editText = ... Read More

Add and Remove Views in Android Dynamically?

Azhar
Updated on 03-Jul-2020 06:43:35

3K+ Views

This example demonstrates how to Add and Remove Views in Android Dynamically.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.xml.                               Step 2 − Add the following code to res/layout/field.xml             Step 3 − Add the following code to res/values/strings.xml    Sample           Mobile       ... Read More

How to start service using Alarm Manager in android?

Azhar
Updated on 03-Jul-2020 06:44:23

1K+ Views

This example demonstrates how do I start a service using alarm manager 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.xml.         Step 3 − Add the following code to src/MainActivity.javapackage app.com.sample; import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; import java.util.Calendar; public class MainActivity extends AppCompatActivity {    Button btnStart, btnStop;    PendingIntent pendingIntent;    @Override    protected void onCreate(Bundle savedInstanceState) ... Read More

Advertisements