How will you reference a textbox control in java file, that is available in XML file and the ID is txtName.

How will you reference a textbox control in java file, that is available in XML file and the ID is txtName.



A) EditText txtEmpName;

txtEmpName=findViewById(R.id.txtName);

B) EditText txtEmpName;

txtEmpName=(EditText)findViewById(R.id.txtName);

C) EditText txtEmpName;

txtEmpName=(EditText)findViewById(txtName);

D) None of the above.


Answer: B


Learn More :