Mobile Development Articles

Page 50 of 156

How to get selected Index of the Radio group in Android?

Azhar
Azhar
Updated on 02-Jul-2020 4K+ Views

This example demonstrates how do I get selected index of the radio group 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.Button; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView textView;    Button button;    RadioGroup radioGroup;   ...

Read More

How to set a particular font for a button text in Android?

Azhar
Azhar
Updated on 02-Jul-2020 1K+ Views

This example demonstrates how do I set a particular font for a button text 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.view.View; import android.widget.Button; import static android.graphics.Typeface.BOLD_ITALIC; public class MainActivity extends AppCompatActivity {    Button btnChangeFont, btnChangeFont2;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main); ...

Read More

How to pass values between Fragments in Android?

Azhar
Azhar
Updated on 02-Jul-2020 1K+ Views

This example demonstrates how do I pass values between fragments 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.Menu; import android.view.MenuItem; public class MainActivity extends AppCompatActivity implements FragmentOne.OnFragmentInteractionListener{    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    }    @Override    public boolean onCreateOptionsMenu(Menu menu) {     ...

Read More

How to prevent a dialog from closing when a button is clicked?

Azhar
Azhar
Updated on 02-Jul-2020 2K+ Views

This example demonstrates how do I prevent a dialog from closing when a button is 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.AlertDialog; 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 extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       final AlertDialog dialog = new ...

Read More

What is difference between FillParent and wrap content in android?

Azhar
Azhar
Updated on 02-Jul-2020 3K+ Views

This example demonstrates how do I show the difference between fillParent and wrap content 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 implement Android button Sheet widget?

Azhar
Azhar
Updated on 02-Jul-2020 405 Views

This example demonstrates how do I implement android button sheet widget.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 − Open build.gradle (Module:app) and add the following dependencyimplementation 'com.android.support:design:28.0.0' implementation 'com.jakewharton:butterknife:8.8.1' annotationProcessor 'com.jakewharton:butterknifecompiler:8.8.1'Step 4 − Create a layout (bottomsheet.xml) and the following code −                           ...

Read More

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

Azhar
Azhar
Updated on 02-Jul-2020 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

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

Azhar
Azhar
Updated on 02-Jul-2020 3K+ 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
Azhar
Updated on 02-Jul-2020 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 use SharedPrefernces in Android?

Azhar
Azhar
Updated on 02-Jul-2020 143 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
Showing 491–500 of 1,551 articles
« Prev 1 48 49 50 51 52 156 Next »
Advertisements