get Int From TextView Safe - Android User Interface

Android examples for User Interface:TextView Value

Description

get Int From TextView Safe

Demo Code


//package com.java2s;

import android.widget.TextView;

public class Main {
    public static int getIntFromTextViewSafe(TextView view) {
        if (view.getText() == null || view.getText().toString().isEmpty()) {
            return 0;
        }// w  w w  .ja  va 2 s .co m

        return Integer.parseInt(view.getText().toString());
    }
}

Related Tutorials