Monday, 22 July 2013

Display a String message in Android using Toast Method

Toast method is used to display messages in Android.
It can only display String Variables.
To display any Integer variable value convert the Integer into String.

 Example    
   int x=10; 
  String a=""+ x;

Toast Method Syntax:

Toast.makeText("classname.this",a,2000).show();

It will display String 'a' for 2secs.

Friday, 19 July 2013

Number Picker Example in Android

Setting Up a Number Picker in Android

    final NumberPicker np = (NumberPicker) findViewById(R.id.numberPicker1);

        np.setMaxValue(20);

        np.setMinValue(1);

        np.setWrapSelectorWheel(true);

        int value =np.getValue();                 // get the selected value  //write this on button click

Passing Values from one page to other page in android

Passing Values from  one activity to other activity in android


Use Bundle to accomplish this task





1st activity
final Bundle bundle = new Bundle();
bundle.putString("data", name);
i.putExtras(bundle);  //before starting 2nd activity  i.e startActivity(i);

2nd Activity
final Bundle bundle = new Bundle();
Bundle bundle = getIntent().getExtras();
  String name = bundle.getString("data");