- 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)
2K+ Views
This example demonstrates how to put a ListView into a ScrollView without it collapsing 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 android.widget.ArrayAdapter; import android.widget.ListView; public class MainActivity extends AppCompatActivity { private String listview_array[]={ "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN" ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
3K+ Views
This example demonstrates how do I download and save an image from a given 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.Activity; import android.app.ProgressDialog; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.AsyncTask; import android.support.design.widget.CoordinatorLayout; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.Toast; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
1K+ Views
This example demonstrates how do I get android device screen height, width.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.util.DisplayMetrics; import android.widget.TextView; public class MainActivity extends AppCompatActivity { TextView height, width, inches; DisplayMetrics displayMetrics; @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)
6K+ Views
This example demonstrates how to load an ImageView by 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.javapackage com.example.sample; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.AsyncTask; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.widget.ImageView; import android.widget.Toast; import java.io.InputStream; 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)
2K+ Views
This example demonstrates how do I get the height and width of the android.widget.ImageView 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.Button; import android.widget.ImageView; import android.widget.TextView; public class MainActivity extends AppCompatActivity { TextView textView; Button button; ImageView imageView; @Override protected void onCreate(Bundle savedInstanceState) { ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
1K+ Views
This example demonstrates how do I set locale 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 – Create a directory (values-es) and copy the string.xml file into this directory and make the below changes Sample Que tengas un buen día Step 4 − Add the following code to src/MainActivity.javaimport android.content.res.Configuration; import android.content.res.Resources; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.DisplayMetrics; import java.util.Locale; public class MainActivity extends AppCompatActivity { @Override ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
9K+ Views
This example demonstrates how do I read a file from assets 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 – Right click app >> New >> Folder >> Assets folder. Right click on the assets folder, select New >> file (myText.txt) and your text.“Darkness cannot drive out darkness: only light can do that. Hate cannot drive out hate: only love can do that.”Step 4 − Add the following ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
724 Views
This example demonstrates how do I change the spinner textSize and textColor 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.widget.ArrayAdapter; import android.widget.Spinner; public class MainActivity extends AppCompatActivity { Spinner spinner; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); spinner = findViewById(R.id.spinner); String[] superHero = ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
7K+ Views
This example demonstrates how do I show current location on a google map 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 dependency in the build.gradle (Module: app)implementation 'com.google.android.gms:play-services-maps:17.0.0' implementation 'com.google.android.gms:play-services-location:17.0.0'Step 4 − Add the following code to src/MainActivity.javaimport android.Manifest; import android.content.pm.PackageManager; import android.location.Location; import android.os.Bundle; import android.widget.Toast; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.location.FusedLocationProviderClient; import com.google.android.gms.location.LocationServices; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.gms.tasks.OnSuccessListener; import com.google.android.gms.tasks.Task; import androidx.annotation.NonNull; import androidx.core.app.ActivityCompat; ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
5K+ Views
This example demonstrates how do I set background drawable 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.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.RelativeLayout; public class MainActivity extends AppCompatActivity { Button button; RelativeLayout relativeLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); relativeLayout = findViewById(R.id.rl); ... Read More