Stormy Chase Forrester Stormy Chase Forrester - 1 year ago 96
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(;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download