Scanner scanner = new Scanner(lapsPerMile_st);
if (!scanner.hasNextDouble()) {
Context context = getApplicationContext();
String msg = "Please Enter Digits and Decmials Only";
int duration = Toast.LENGTH_LONG;
Toast.makeText(context, msg, duration).show();
lapsPerMileEditText.setText("");
return;
} else {
//Edit box has only digits, Set data and display stats
data.setLapsPerMile(Integer.parseInt(lapsPerMile_st));
lapsRunLabel.setVisibility(0);
lapsRunTextView.setText(Integer.toString(data.getLapsRun()));
milesRunLabel.setVisibility(0);
milesRunTextView.setText(Double.toString(data.getLapsRun()/data.getLapsPerMile()));
}
<EditText
android:id="@+id/mileCount"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="110dp"
android:inputType="numberDecimal"
android:maxLength="4"
/>
For some reason if I enter a non decimal number such as 3, or 5, it works fine but when I enter a floating point such as 3.4 or 5.8 it force closes. I cant seem to figure out whats going on. Any ideas?
Thanks