Found 1966 Articles for Apps/Applications

How to handle the click event in ListView in android?

Azhar
Updated on 31-Jul-2019 10:08:52

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

How to change the color of the Check box in Android?

Azhar
Updated on 31-Jul-2019 09:24:05

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

How to apply a theme to an activity only in Android?

Azhar
Updated on 31-Jul-2019 09:19:38

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

How to download image from url in Android?

Azhar
Updated on 01-Aug-2019 06:59:40

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

How to handle a back button in an android activity?

Azhar
Updated on 31-Jul-2019 09:09:06

2K+ Views

This example demonstrates how do I handle back button in an android activity.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.support.v7.app.AppCompatActivity; 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 = findViewById(R.id.button);     ... Read More

How does Activity.finish() work in Android?

Azhar
Updated on 31-Jul-2019 09:04:01

5K+ Views

This example demonstrates how Activity.finish() work 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.Intent; 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 = (Button) findViewById(R.id.button);       button.setOnClickListener(new View.OnClickListener() { ... Read More

How do I prevent an Android device from going to sleep mode?

Azhar
Updated on 31-Jul-2019 08:57:40

732 Views

This example demonstrates how do I prevent an Android device from going to sleep mode.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.WindowManager; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);    } }Step 4 − Add the following code ... Read More

What is difference between onCreate() and onStart() on Android?

Azhar
Updated on 31-Jul-2019 08:52:48

2K+ Views

This example demonstrates the difference between onCreate() and onStart() in Android.Note −onCreate() is called when the when the activity is first created.onStart() is called when the activity is becoming visible to the user.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.Log; public class MainActivity extends AppCompatActivity {    public static final String TAG = "Have a nice day!"; ... Read More

How to convert pixels to DP’s in Android app?

Azhar
Updated on 31-Jul-2019 08:48:34

186 Views

This example demonstrates about How do I convert Pixels to DP’s 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.Context; import android.content.res.Resources; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.RelativeLayout; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       ... Read More

How to limit Decimal Places in Android EditText?

Azhar
Updated on 31-Jul-2019 08:31:28

4K+ Views

This example demonstrates about How to limit Decimal Places in Android EditText.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.os.Bundle; import android.text.InputFilter; import android.text.Spanned; import android.widget.EditText; import java.util.regex.Matcher; import java.util.regex.Pattern; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       EditText etText = ... Read More

Advertisements