Reputation: 800
I have the following code:
public void onClickV(View view){
String title = "Go To...";
}
public void showDialog (View arg0) {
dialog.setTitle(this.String.title);
}
But the "this.String.title" isn't working at all. How could I set the title of the dialog depending on what the string is set to by an onClick method?
Thanks
EDIT: How would I do something similar for images?
Upvotes: 0
Views: 69
Reputation:
Don't use harcoded String. Use a string ressource.
In strings.xml
<string name="title">Go to...</string>
In Activity.java
public void showDialog(View arg0) {
dialog.setTitle(getString(R.string.title));
}
Upvotes: 2
Reputation: 93842
Declare a variable outside the function.
String title;
public void onClickV(View view){
title = "Go To...";
}
public void showDialog (View arg0) {
dialog.setTitle(title);
}
Upvotes: 3