Found 1626 Articles for Android

How to make a specific text on TextView bold in Android?

Azhar
Updated on 02-Aug-2019 08:24:31

5K+ Views

This example demonstrates how do I make a specific text on TextView bold 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.Typeface; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.SpannableString; import android.text.Spanned; import android.text.style.StyleSpan; 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);     ... Read More

How can I generate random number in a given range in Android?

Azhar
Updated on 02-Aug-2019 08:19:13

1K+ Views

This example demonstrates how do I generate random number in a given range 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.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import java.util.Random; public class MainActivity extends AppCompatActivity {    EditText et_min, et_max;    Button btn_generate;    TextView tv_output;    Random r;    int ... Read More

How to use ArrayAdapter in android to create simple ListView?

Azhar
Updated on 02-Aug-2019 08:13:25

681 Views

This example demonstrates how do I detect user pressing home key in an activity 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.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView; public class MainActivity extends AppCompatActivity {    ListView simpleList;    String playersList[] = {"Ronaldo", "Messi", "Neymar", "Isco", "Hazard"};    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);     ... Read More

How to detect user pressing Home Key in an Activity on Android?

Azhar
Updated on 02-Aug-2019 08:08:34

566 Views

This example demonstrates how do I detect user pressing home key in an activity 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.javaimport 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 textView;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       textView = ... Read More

How to close all activities at once in android?

Azhar
Updated on 02-Aug-2019 08:03:06

2K+ Views

This example demonstrates how do I close all activities at once in 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.javaimport android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity {    Button button;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       button = ... Read More

How to pick an image from image gallery in Android?

Azhar
Updated on 02-Aug-2019 07:56:39

4K+ Views

This example demonstrates how do I pick an image from image gallery in android appStep 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.content.Intent; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.view.View; import android.widget.Button; import android.widget.ImageView; public class MainActivity extends Activity {    ImageView imageView;    Button button;    private static final int PICK_IMAGE = 100;    Uri imageUri; ... Read More

How to create a scrollable textView Android app?

Azhar
Updated on 02-Aug-2019 07:48:11

2K+ Views

This example demonstrates how do I create a scrollable textView in 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 app.com.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.method.ScrollingMovementMethod; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       TextView textView = (TextView) findViewById(R.id.textView);       ... Read More

How to create a WebView in android app?

Azhar
Updated on 02-Aug-2019 07:38:20

3K+ Views

This example demonstrates how do I create a WebView in 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.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; 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);       setContentView(R.layout.activity_main);       WebView webView = ... Read More

Custom progress Bar in Android?

Azhar
Updated on 02-Aug-2019 07:32:51

998 Views

This example demonstrates how do I create a progress bar androidStep 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 drawable resource file, name it as circle.xml and add the following code −    Step 4 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ProgressBar; public class MainActivity extends AppCompatActivity {    ProgressBar progressBar;    @Override    protected void onCreate(Bundle savedInstanceState) {     ... Read More

How to change the app language programmatically in android?

Azhar
Updated on 02-Aug-2019 07:27:25

2K+ Views

This example demonstrates how do I in change the app language programmatically 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.res.Configuration; import android.content.res.Resources; import android.os.Build; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.DisplayMetrics; import java.util.Locale; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setAppLocale("bg");       setContentView(R.layout.activity_main);    }   ... Read More

Advertisements