Found 1626 Articles for Android

How can I set a Border for an ImageView in Android?

Azhar
Updated on 05-Aug-2019 10:32:52

4K+ Views

This example demonstrates how do I can I set a border for an 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 projectStep 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 − Create a layout from in res/layout and add the ... Read More

How do I create a listView with rounded corners in Android?

Azhar
Updated on 05-Aug-2019 10:29:11

892 Views

This example demonstrates how do I create a listView with rounded corners 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.ListView; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       ListView listView = findViewById(R.id.listView);       ... Read More

How to open a website in Android’s web browser from any application?

Azhar
Updated on 05-Aug-2019 10:22:30

2K+ Views

This example demonstrates how do I open a website in Android’s web browser from any application.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.Intent; import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       Button button = ... Read More

How to create multiple styles inside a TextView in Android?

Azhar
Updated on 05-Aug-2019 10:07:12

1K+ Views

This example demonstrates how do I create multiple styles inside a TextView 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.text.Html; import android.text.Spanned; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView textView1, textView2, textView3;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);   ... Read More

How to I connect to wifi network on Android programmatically?

Azhar
Updated on 05-Aug-2019 10:00:35

2K+ Views

This example demonstrates how do I connect wifi network in Android programatically.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.Context; import android.net.wifi.WifiManager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.CompoundButton; import android.widget.Switch; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    Switch WiFiButton;    TextView textview;    WifiManager wifiManager;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);   ... Read More

How to get the IP address of android device programmatically?

Azhar
Updated on 05-Aug-2019 09:04:32

7K+ Views

This example demonstrates how do I get the IP address of android device 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 − Add the following code to src/MainActivity.javaimport android.net.wifi.WifiManager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.format.Formatter; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView textView;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       textView = findViewById(R.id.getIPAddress);   ... Read More

How to dismiss the dialog with the click on outside of the dialog box in android?

Azhar
Updated on 05-Aug-2019 08:59:49

1K+ Views

This example demonstrates how do I dismiss the dialog with the click on outside of the dialog 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.annotation.TargetApi; import android.content.DialogInterface; import android.os.Build; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    TextView text;    @TargetApi(Build.VERSION_CODES.LOLLIPOP)    @Override    protected void onCreate(Bundle savedInstanceState) ... Read More

How to programmatically prevent scrolling in webView in Android?

Azhar
Updated on 05-Aug-2019 08:52:47

2K+ Views

This example demonstrates how do I programmatically prevent scrolling in webView 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.MotionEvent; import android.view.View; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends AppCompatActivity {    private WebView webView;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       ... Read More

How to change the DatePicker Dialog color in Android?

Azhar
Updated on 05-Aug-2019 08:42:46

4K+ Views

This example demonstrates how do I change the DatePicker dialog color 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.     Kindly fine the highlighted code, this is the simplest way to change the colour of your datePicker.Step 3 − Add the following code to src/MainActivity.javaimport android.annotation.TargetApi; import android.os.Build; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.DatePicker; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    @TargetApi(Build.VERSION_CODES.O)    @Override    protected void onCreate(Bundle savedInstanceState) ... Read More

How to programmatically scroll to a specific position in listView in Android?

Azhar
Updated on 05-Aug-2019 08:38:18

2K+ Views

This example demonstrates how do I programmatically scroll to a specific position 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.os.Bundle; import android.app.Activity; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class MainActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main); ... Read More

Advertisements