i have a setText method that seems to be fine and my code is perfect but it is still giving me an error when running the app.
my code:
public class DetailsActivity extends AppCompatActivity {
TextView textTitle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details);
textTitle = findViewById(R.id.details_shopName);
Intent i = getIntent();
String textTitle = i.getStringExtra("title");
textTitle.setText(textTitle);
}
}
THE ERROR READS:
error: cannot find symbol
textTitle.setText(textTitle);
^
symbol: method setText(String)
location: variable textTitle of type String1
You have two conflicting variable names. This should work fine
public class DetailsActivity extends AppCompatActivity {
TextView textTitle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details);
textTitle = findViewById(R.id.details_shopName);
Intent i = getIntent();
String title = i.getStringExtra("title");
textTitle.setText(title);
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments