Found 2041 Articles for Mobile Development

How to make a GridLayout fit screen size in Android?

Azhar
Updated on 09-Jul-2020 12:07:43

1K+ Views

This example demonstrates how How to make a GridLayout fit screen size 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 com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.Gravity; import android.widget.GridLayout; import android.widget.ImageView; ... Read More

How to Justify Text in TextView in Android?

Azhar
Updated on 26-Nov-2019 09:45:20

535 Views

This example demonstrates how to Justify Text in TextView 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 res/layout/list_item.xml             Step 4 − Add the following code to src/MainActivity.javapackage com.app.sample; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.os.Bundle; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity {    private final String TAG = "MainActivity";    private ... Read More

How to detect user inactivity for 5 seconds in Android?

Azhar
Updated on 26-Nov-2019 09:37:18

1K+ Views

This example demonstrates how to detect user inactivity for 5 seconds 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 com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.os.Handler; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    Handler handler;    Runnable r;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       handler = ... Read More

How to scale an Image in ImageView to keep the aspect ratio in Android?

Azhar
Updated on 26-Nov-2019 08:15:19

1K+ Views

This example demonstrates how to scale an Image in ImageView to keep the aspect ratio 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 com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.ImageView; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       ImageView my_image = (ImageView) findViewById(R.id.my_image);   ... Read More

How to support different screen size in Android?

Azhar
Updated on 26-Nov-2019 08:12:25

1K+ Views

This example demonstrates how to support different screen sizes 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 com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.util.DisplayMetrics; import android.widget.TextView; import android.os.Bundle; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       DisplayMetrics metrics = new DisplayMetrics();       ... Read More

How to write a SoftKeyboard open and close listener in an activity in Android?

Azhar
Updated on 26-Nov-2019 08:08:50

1K+ Views

This example demonstrates how to write a SoftKeyboard open and a close listener in activity 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 com.app.sample; import androidx.annotation.RequiresApi; import androidx.appcompat.app.AppCompatActivity; import androidx.constraintlayout.widget.ConstraintLayout; import android.os.Bundle; import android.graphics.Rect; import android.os.Build; import android.view.View; import android.view.ViewTreeObserver; import android.view.inputmethod.InputMethodManager; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends AppCompatActivity implements View.OnClickListener{    ConstraintLayout ... Read More

How to add jar as library on Android Studio?

Azhar
Updated on 26-Nov-2019 08:05:08

1K+ Views

This example demonstrates how to add jar as a library on Android Studio.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 jar file to Project/app/libs/Step 3 − Add the following dependencies to File/Project StructureStep 4 − Add the following code to res/layout/activity_main.xml.     Step 5 − Add the following code to src/MainActivity.javapackage com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);     ... Read More

How to send Email on Android using JavaMail API?

Azhar
Updated on 26-Nov-2019 07:57:24

3K+ Views

This example demonstrates how to send Email on Android using JavaMail API.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.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import java.util.Properties; import javax.mail.PasswordAuthentication; import javax.mail.Session; import android.os.Bundle; public class MainActivity extends AppCompatActivity implements View.OnClickListener {    private EditText editTextEmail;    private ... Read More

How to disable copy/paste from/to EditText in Android App?

Azhar
Updated on 26-Nov-2019 07:49:25

793 Views

This example demonstrates how do I disable copy/paste from/to 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 androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.widget.EditText; public class MainActivity extends AppCompatActivity {    EditText editText;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       editText = ... Read More

How to find out if the GPS of an Android device is enabled or not?

Azhar
Updated on 26-Nov-2019 07:46:30

228 Views

This example demonstrates how do I find out if the GPS of an Android device is enabled or not.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 androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import android.content.DialogInterface; import android.content.Intent; import android.location.LocationManager; import android.os.Bundle; import android.widget.Toast; import java.util.Objects; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       ... Read More

Advertisements