- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1631 Articles for Android
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
1K+ Views
This example demonstrates about How to implement a long click listener on a 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.javapackage app.com.sample; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity { String[] mobileArray = {"Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X"}; @Override protected void ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
710 Views
This example demonstrates about How to launch activity only once when Android app is opened for the first time.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 androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; public class MainActivity extends AppCompatActivity { String prevStarted = "prevStarted"; @Override protected void onResume() { super.onResume(); SharedPreferences sharedpreferences ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
870 Views
This example demonstrates about How to store drawable resources ID in the form of R.drawable.* inside an array using an XML values fileStep 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/values/ arrays.xml. @drawable/image1 @drawable/image2 @drawable/image3 Step 3 − Add the following code to res/layout/activity_main.xml. Step 4 − Add the following code to src/MainActivity.javapackage app.com.sample; ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
525 Views
This example demonstrates how do I take a screenshot in Android 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.xml. Step 3 − Create a new Java Class and add the following code in screenshot.javaimport android.graphics.Bitmap; import android.view.View; public class Screenshot{ public static Bitmap takescreenshot(View v) { v.setDrawingCacheEnabled(true); v.buildDrawingCache(true); Bitmap b = Bitmap.createBitmap(v.getDrawingCache()); v.setDrawingCacheEnabled(false); ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
839 Views
This example demonstrates how do I disable orientation change 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.content.pm.ActivityInfo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setContentView(R.layout.activity_main); } }Step 4 − Add the following code to androidManifest.xml ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
2K+ Views
This example demonstrates how do I set Android Wallpaper image 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 projectStep 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javaimport android.app.WallpaperManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; import java.io.IOException; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
5K+ Views
This example demonstrates how do I handle the click event in 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 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
5K+ Views
This example demonstrates how do I change the color of the check box 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.graphics.Color; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.CheckBox; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
604 Views
This example demonstrates how do I apply theme to an 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.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; 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
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
3K+ Views
This example demonstrates how do I download image from url 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.app.ProgressDialog; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.AsyncTask; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; import java.io.InputStream; public class MainActivity extends AppCompatActivity { String url = "https://images.pexels.com/photos/1226302/pexels-photo1226302.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"; ImageView image; Button button; ProgressDialog mProgressDialog; ... Read More