Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.widget.EditText;

public class Main {
    public static void incrementEditText(EditText et) {
        String current = et.getText().toString();
        if (current.length() == 0) {
            et.setText("1");
        }
        double doubleValue = Double.valueOf(et.getText().toString());
        int intValue = (int) doubleValue;
        if (doubleValue == intValue) {
            String incremented = String.valueOf(intValue + 1);
            et.setText(incremented);
        } else {
            String incremented = String.valueOf(doubleValue + 1d);
            et.setText(incremented);
        }
        et.clearFocus();
    }
}