I have seen many Q&A on stack about it but for some reason they do not work in my case.
I think it might be because I'm working with elements from and to the view directly.
This code is working;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void btnOnClickRegister(View view){
TextView txtEmail = findViewById(R.id.txtEmail);
EditText edtTxtEmail = findViewById(R.id.edtTxtEmail);
txtEmail.setText("Email "+ edtTxtEmail.getText().toString()); //hardcoded and will not translate
}
}
In the strings.xml;
<string name="email">Email</string>
I get the following warning;
Do not concatenate text displayed with setText. Use resource string with placeholders.
Most Q&A resolve this like so;
getString(R.string.email, VarContainingEmail);
with an XML that look like this;
<string name="email">Email %s</string>
If I try that I get the following warning;
Cannot resolve method 'getString' in 'TextView'
I'm just starting with android studio and would like to resolve this right off the start.
I'm using Android Studio version 4.0.1