Method cannot resolve for TextView in this code
What is wrong with this?
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
EditText Username = (EditText) findViewById(R.id.EmployerNameEdit);
String userName = Username.getText().toString();
TextView changedName = (TextView) findViewById(R.id.employerName);
changedName.setText(userName);
}
Every thing in oncreate or create global edittext and TextView
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText Username = (EditText) findViewById(R.id.EmployerNameEdit);
String userName = Username.getText().toString();
TextView changedName = (TextView) findViewById(R.id.employerName);
changedName.setText(userName);
}
might be you missed curly bracket,
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText Username = (EditText) findViewById(R.id.EmployerNameEdit);
String userName = Username.getText().toString();
TextView changedName = (TextView) findViewById(R.id.employerName);
changedName.setText(userName);
}
}
if you still getting problem, please fell free to ask question. :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.