Converting EditText to int? (Android)

android, android-edittext, integer

Solution

you have to used.

String value= et.getText().toString();
int finalValue=Integer.parseInt(value);

if you have only allow enter number then set EditText property.

android:inputType="number"

if this is helpful then accept otherwise put your comment.

Problem

I am wondering how to convert an `EditText` input to an int, I have the user input a number, which then divides it by 8. MainActivity.java: ``` @SuppressWarnings("unused") public void calcSpeed(View view) { setContentView(R.layout.activity_speed); final TextView mTextView = (TextView) findViewById(R.id.textView3); mTextView.setText("You should be getting: " +netSpedCalcd); } ``` activity_main.xml: ``` <EditText android:id="@+id/editText1" android:inputType="number" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_marginTop="62dp" android:ems="10" > ```

Original source

Related problems