Found 1966 Articles for Apps/Applications

How to get the height and width of the android.widget.ImageView?

Azhar
Updated on 03-Jul-2020 06:29:21

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

How to set locale programmatically in android app?

Azhar
Updated on 03-Jul-2020 06:32:23

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

How to read a file from assets on android?

Azhar
Updated on 03-Jul-2020 06:33:10

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

How to change the spinner textSize and textColor in Android app?

Azhar
Updated on 03-Jul-2020 06:33:51

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

How to show current location on a google map on Android?

Azhar
Updated on 30-Aug-2019 14:02:32

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

How to set background drawable programmatically in android?

Azhar
Updated on 03-Jul-2020 06:36:44

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

How to parse JSON Objects on Android?

Azhar
Updated on 03-Jul-2020 06:00:38

524 Views

This example demonstrates how to parse JSON Objects 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 dependency to Gradle Scripts ⇒ build.gradle and do syncapply plugin: 'com.android.application' android {    compileSdkVersion 28    defaultConfig {       applicationId "com.example.sample"       minSdkVersion 21       targetSdkVersion 28       versionCode 1       versionName "1.0"       testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"    }    buildTypes {       release { ... Read More

How to make an ImageView with rounded corners on Android App?

Azhar
Updated on 03-Jul-2020 06:01:17

6K+ Views

This example demonstrates how to make an ImageView with rounded corners on Android App.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.BitmapShader; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.RectF; import android.graphics.Shader; import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.ImageView; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) ... Read More

How to parse JSON on Android?

Azhar
Updated on 03-Jul-2020 06:01:52

217 Views

This example demonstrates how to parse JSON 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.myapplication; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; import org.json.JSONException; import org.json.JSONObject; public class MainActivity extends AppCompatActivity {    String JSON_STRING="{\"employee\":{\"name\":\"adolf hitler\", \"salary\":65000}}";    String name, salary;    TextView employeeName, employeeSalary;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);     ... Read More

How to make an android spinner with initial default text?

Azhar
Updated on 03-Jul-2020 06:03:10

7K+ Views

This example demonstrates how do I make an android spinner with initial default text 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.Spinner; import android.widget.Toast; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity {    Spinner spinner;    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState); ... Read More

Advertisements