Found 2041 Articles for Mobile Development

Progress Dialog in Android?

Azhar
Updated on 02-Jul-2020 07:24:23

545 Views

This example demonstrates how do I progress 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 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.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity {    ProgressDialog progressDialog;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       progressDialog = new ProgressDialog(MainActivity.this);       progressDialog.setTitle("My Content");       progressDialog.setMessage("Loading this ... Read More

How to use SharedPrefernces in Android?

Azhar
Updated on 02-Jul-2020 07:26:41

40 Views

This example demonstrates how do I use shared preferences 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.SharedPreferences; import android.preference.PreferenceManager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; public class MainActivity extends AppCompatActivity {    SharedPreferences sharedPreferences;    SharedPreferences.Editor editor;    EditText name, password;    Button button;    CheckBox checkBox;   ... Read More

How to stop AsyncTask thread in android?

Azhar
Updated on 02-Jul-2020 07:23:38

338 Views

This example demonstrates how do I stop AsynchTask thread 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.os.AsyncTask; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity {    private Button btnDo, btnCancel;    private TextView textView;    private AsyncTask myTask;    @Override    protected ... Read More

How to simulate touch event with android at a given position?

Azhar
Updated on 02-Jul-2020 07:28:41

2K+ Views

This example demonstrates how do I simulate touch even with android at a given position.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.widget.Toast; public class MainActivity extends AppCompatActivity {    private boolean isTouch = false;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    }    @Override    public boolean ... Read More

How to use calendar widget using the calendarView class in Android App?

Azhar
Updated on 02-Jul-2020 07:27:33

1K+ Views

This example demonstrates how do I use calendar widget using the calendarView class 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.annotation.NonNull; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.CalendarView; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    CalendarView calendar;    TextView dateView;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);     ... Read More

How to count number of characters in EditText while typing in android?

Azhar
Updated on 02-Jul-2020 07:29:27

2K+ Views

This example demonstrates how do I count number of characters in editText while typing 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.Editable; import android.text.TextWatcher; import android.widget.EditText; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView textView;    EditText editText;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);     ... Read More

MediaPlayer class to implement a basic Audio Player in an Android App

Azhar
Updated on 02-Jul-2020 07:40:08

209 Views

This example demonstrates how do I create a Mediaplayer class to implement a basic audio player 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.media.MediaPlayer; import android.os.Handler; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.ImageButton; import android.widget.SeekBar; import android.widget.TextView; import android.widget.Toast; import java.util.concurrent.TimeUnit; public ... Read More

How to centre align action bar title in android?

Azhar
Updated on 21-Aug-2019 08:34:07

3K+ Views

This example demonstrates how do I centre align action bar title 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.ActionBar; import 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);       getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);       getSupportActionBar().setCustomView(R.layout.activity_main);    } }Step 4 − Add the ... Read More

How to create a custom alert dialogs in an android app?

Azhar
Updated on 21-Aug-2019 08:32:31

151 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 – Create a layout resourse file and add the following code in customdialog.xml             Step 3 − Add the following code to src/MainActivity.javaimport android.app.Dialog; import android.content.Context; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; public class MainActivity ... Read More

How to change app language when user selects language in Android?

Azhar
Updated on 21-Aug-2019 08:30:37

976 Views

This example demonstrates how do I change app language when user selects language.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.content.res.Configuration; import android.content.res.Resources; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.DisplayMetrics; 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; import java.util.Locale; public class MainActivity extends AppCompatActivity {    Spinner spinner;    Locale locale;    String ... Read More

Advertisements