Found 1626 Articles for Android

How to set the date in datepicker dialog in android?

Azhar
Updated on 01-Aug-2019 07:23:12

1K+ Views

This example demonstrates about how do I set the date in datepicker dialog 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 res/layout/DatePickerFragment.java (Right click on the package, click new – Java Class)import android.app.DatePickerDialog; import android.app.Dialog; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import java.util.Calendar; public class DatePickerFragment extends DialogFragment {    @NonNull    @Override    public Dialog onCreateDialog(Bundle savedInstanceState) {   ... Read More

How to pass a String from one Activity to another in Android?

Azhar
Updated on 31-Jul-2019 07:15:06

307 Views

This example demonstrates about how do I pass a String from one Activity to another 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.javapackage app.com.sample; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; public class MainActivity extends AppCompatActivity {    Button changeActivityButton;    EditText messageEditText;    @Override    protected void onCreate(Bundle savedInstanceState) {       ... Read More

How to change Screen Orientation programmatically using a Button in Android?

Azhar
Updated on 01-Aug-2019 07:21:21

1K+ Views

This example demonstrates about how do I change the Screen Orientation programmatically using a Button 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.javapackage app.com.sample; import android.content.pm.ActivityInfo; 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);       ... Read More

Where and how to use to static variables in android studio?

Azhar
Updated on 01-Aug-2019 07:19:46

645 Views

This example demonstrates about how and where do I use static variable in android studio.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; import android.util.Log; public class MainActivity extends AppCompatActivity {    public static final String TAG = "I'm a Static Variable";    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    } ... Read More

How to load an ImageView by URL on Android using Picasso?

Azhar
Updated on 01-Aug-2019 07:18:59

697 Views

This example demonstrates about how do I load an ImageView on Android using Picasso.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 − Gradle Scripts from Project → Click build.gradle (Module: app) → add dependency − Implementation ‘com.squareup.picasso−Picasso:2.5.2 and click “Sync now”.Step 3 − Add the following code to res/layout/activity_main.xml.             Step 4 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ImageView; import com.squareup.picasso.Picasso; public class MainActivity extends AppCompatActivity {    private ImageView ... Read More

How to get the touch position on android device?

Azhar
Updated on 01-Aug-2019 07:17:40

1K+ Views

This example demonstrates about how do I get the touch position on android device.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.javapackage app.com.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.widget.EditText; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView T;    EditText E1, E2;    float x = 0f;    float y = 0f;   ... Read More

How to call OnDestroy Activity in Android app?

Azhar
Updated on 01-Aug-2019 07:16:37

1K+ Views

This example demonstrates about How do I call OnDestroy Activity 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 com.sample.q2; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; public class MainActivity extends AppCompatActivity {    public static final String MY_TAG = "Destroy";    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       Log.i(MY_TAG, "onCreate"); ... Read More

How to change color of Button in Android when Clicked?

Azhar
Updated on 01-Aug-2019 07:15:44

5K+ Views

This example demonstrates about How do I change the color of Button in Android when clicked.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; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       final Button button = findViewById(R.id.button);     ... Read More

How to disable action bar permanently in Android?

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

545 Views

This example demonstrate about How to disable action bar permanently 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.java     Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.sample ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate (Bundle savedInstanceState) {       super .onCreate(savedInstanceState) ;       setContentView(R.layout. activity_main ) ;    } }Step 4 − Add the ... Read More

How to make a background 25% transparent on Android?

George John
Updated on 30-Jul-2019 22:30:26

321 Views

This example demonstrate about How to make a background 25% transparent 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.java Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.sample ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; 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 ... Read More

Advertisements