web-dev-qa-db-fra.com

Conversion de EditText en int? (Android)

Je me demande comment convertir une entrée edittext en int, j'ai l'utilisateur de saisir un nombre, qu'il divise par 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" >
18
user2101454
int total_Parson = Integer.parseInt(etRegularTickets.getText().toString());
int ticket_price=Integer.parseInt(TicketData.get(0).getTicket_price_regular());
total_ticket_amount = ticket_price * total_Parson;
etRegularPrice.setText(""+total_ticket_amount);
0
Mr.vicky patel