Tags » Android Button

Tutorial: Using a Button To Switch Pages in a ViewPager [Android Studio]

OK, so Android Studio (like its ancient forefather Eclipse) supports the ViewPager navigation type, which allows you to set up multi-page navigation without any work. However, I’ve noticed that many people don’t quite seem to get the hang of swiping and give up on trying to switch pages. 271 more words


Creating a Custom Scalable background

The Android SDK provides a very powerful feature which helps you create cool looking backgrounds for your views and widgets. The best part is you do not have to create or resize any images to fit any device screens and the whole thing is based on simple xml files. 401 more words


Dynamically adding widgets to a User interface

Normally the views defined using the XML layout field can be simply inflated by using the setContetntView(R.layout.main).

The following code is used to add a button dynamically:

public void onCreate(Bundle savedInstanceState) {

   //Inflate the layout file res\layout\activity_uc.xml

   LinearLayout layout = (LinearLayout)getLayoutInflater().inflate(R.layout.main,null);

   //Initiate a new button

   Button reset = new Button(this);
   reset.setText("Reset Form");

   //Add the new button to the layout

   layout.addView(reset,new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,


   //Attach the view to the window


… 13 more words

Creating a One activity Application


We are going to design a simple application which basically converts between different units of Measurement.  And the user can select an option from a dropdown(called Spinner in Android) and enter the quantity needed to be converted in a Textbox and click on the Convert button and the converted value is displayed in the same textbox(EditText in Android). 790 more words