Found 1631 Articles for Android

How to play videos in Android TextureView?

Azhar
Updated on 08-Jul-2020 06:06:21

1K+ Views

This example demonstrates how do I play videos in Android TextureView.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 an asset folder and copy-paste the video into the asset folder.Step 4 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.content.res.AssetFileDescriptor; import android.graphics.SurfaceTexture; import android.media.MediaPlayer; import android.os.Build; import android.os.Bundle; import android.view.Surface; import android.view.TextureView; import java.io.IOException; public class MainActivity extends AppCompatActivity implements TextureView.SurfaceTextureListener, MediaPlayer.OnVideoSizeChangedListener {    TextureView textureView;    private ... Read More

How to detect scroll up and scroll down in android listView?

Azhar
Updated on 08-Jul-2020 05:55:30

1K+ Views

This example demonstrates how do I detect scroll up and down in android listView.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.widget.AbsListView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.ScrollView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    ScrollView scrollView;    ListView listView;    String[] numbers = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "X", "11", "12", "13", ... Read More

Playing an Arbitrary tone with Android?

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

165 Views

This example demonstrates how do I playing an arbitrary tone with 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.media.AudioFormat; import android.media.AudioManager; import android.media.AudioTrack; import android.os.Bundle; import android.os.Handler; public class MainActivity extends AppCompatActivity {    private final int duration = 10;    private final int sampleRate = 8000;    private final int numSamples = duration * sampleRate;   ... Read More

How to detect orientation change in layout in android?

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

1K+ 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

725 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

916 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

307 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

5K+ 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

707 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

297 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

Advertisements