Monthly Archives: February 2013

Getting Selected Radio Button Value from Radio Group in Android

// Gets a reference to our radio group
// rBtnDigits is the name of our radio group (code not shown)
RadioGroup g = (RadioGroup) findViewById(R.id.rBtnDigits); 

// Returns an integer which represents the selected radio button's ID
int selected = g.getCheckedRadioButtonId();

// Gets a reference to our "selected" radio button
RadioButton b = (RadioButton) findViewById(selected);

// Now you can get the text or whatever you want from the "selected" radio button
b.getText();

Regular expression for a positive double number in a text box?

public static boolean isDouble(String itemPrice)
{
return itemPrice.matches(“^[+]?\\d{0,10}+(\\.{0,1}(\\d{0,3}))?$”);
}

double values like True when

5

.5

5.

5.5

When False values like

2..2

3,2

$3

afs

a/.sdf

 

%d bloggers like this: