Found 1626 Articles for Android

How to detect orientation change in layout in android?

Azhar
Updated on 08-Jul-2020 05:58:15

2K+ Views

This example demonstrates how do I detect orientation change in layout 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.content.res.Configuration; 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);    }    @Override    public void onConfigurationChanged(Configuration newConfig) {       super.onConfigurationChanged(newConfig); ... Read More

How to create Horizontal ListView in Android?

Azhar
Updated on 08-Jul-2020 05:38:50

1K+ Views

This example demonstrates how do I create Horizontal ListView 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.Kindly add the below-given dependence in the Gradle −implementation 'com.android.support:recyclerview-v7:28.0.0' implementation 'com.android.support:cardview-v7:28.0.0'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 androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.os.Bundle; import java.util.ArrayList; import java.util.Arrays; public class MainActivity extends AppCompatActivity {    RecyclerView recyclerView;    RecyclerView.LayoutManager layoutManager;    RecyclerView.Adapter adapter;    ArrayList numberName;    ArrayList numberImage;    @Override ... Read More

How to add google search functionality in an android app?

Azhar
Updated on 08-Jul-2020 05:19:22

1K+ Views

This example demonstrates how do I add google search functionality in an 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.app.SearchManager; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; public class MainActivity extends AppCompatActivity {    EditText editText;    Button btnSearch;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);   ... Read More

How can I get zoom functionality for images on Android?

Azhar
Updated on 08-Jul-2020 05:20:04

441 Views

This example demonstrates how do I get zoom functionality for images 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.import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.MotionEvent; import android.view.ScaleGestureDetector; import android.widget.ImageView; public class MainActivity extends AppCompatActivity {    private ScaleGestureDetector scaleGestureDetector;    private float scaleFactor = 1f;    private ImageView imageView;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       imageView = findViewById(R.id.imageView);       ... Read More

How to convert Drawable to a Bitmap in Android?

Azhar
Updated on 08-Jul-2020 05:20:37

6K+ Views

This example demonstrates how do I convert Drawable to a Bitmap 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.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    ImageView imageView;    Button btnConvert;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);   ... Read More

How to create focusable editText inside ListView on Android?

Azhar
Updated on 08-Jul-2020 05:21:09

916 Views

This example demonstrates how do I create a focusable editText inside ListView 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 new layout resource file and add the following code−         Step 4 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.annotation.SuppressLint; import android.app.LauncherActivity; import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.EditText; import ... Read More

How to make an Android SlidingDrawer slide out from the left?

Azhar
Updated on 08-Jul-2020 05:21:41

379 Views

This example demonstrates how do I make an android slidingdrawer slide out from the left 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; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       ... Read More

How to get all checked items in a listView in Android?

Azhar
Updated on 07-Jul-2020 13:45:41

2K+ Views

This example demonstrates how do I get all checked items in a listView 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 java class (CustomAdapter.java) and the following code −import android.annotation.SuppressLint; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.CheckBox; import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; import java.util.Objects; class CustomAdapter extends BaseAdapter {    private ... Read More

How To Make Circle Custom Progress Bar in Android?

Azhar
Updated on 07-Jul-2020 13:47:56

1K+ Views

This example demonstrates how do I make circle custom progress bar 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(circularprogressbar.xml) and add the following code −                                                                   ... Read More

How to disable GridView scrolling in Android?

Azhar
Updated on 07-Jul-2020 13:48:39

812 Views

This example demonstrates how do I disable gridView scrolling 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.annotation.SuppressLint; import android.content.Context; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ImageView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    GridView gridView;    Integer[] imageIDs = {R.drawable.one, R.drawable.two, R.drawable.three, R.drawable.four, R.drawable.five, R.drawable.six, R.drawable.seven, R.drawable.eight, R.drawable.nine, R.drawable.ten};   ... Read More

Advertisements