Stormy Chase Forrester Stormy Chase Forrester - 11 months ago 46
Android Question

Incovertable types; Canot cast 'android.view.View' to int'

The Phone and etAdress are coming up with the error below:

Canot cast 'android.view.View' to int'

public class register extends AppCompatActivity {

private EditText Name;
private int Phone;
private EditText etEmailUser;
private EditText Address;
private EditText txtPassword;
private FirebaseAuth firebaseAuth;@
protected void onCreate(Bundle savedInstanceState) {
Name = (EditText) findViewById(;
Phone = (int) findViewById(;
etEmailUser = (EditText) findViewById(;
etAddress = (EditText) findViewById(;
firebaseAuth = FirebaseAuth.getInstance();

What am I doing wrong?

Answer Source

The reason is findViewById( will return a View not an int. In your case I think etPhone is an EditText so you should change Phone type to EditText

private EditText Phone;
     Phone = (EditText) findViewById(;