0

In a couple of places in my code, I've used a method to set the text of a view instead of directly setting it. What I mean is that rather than doing:

editText.setText(myString);

I've used a method as follows:

public void setText(EditText editText, String myString) {
     editText.setText(myString);
}

(Obviously this looks a little superfluous; I used this so I could check properties of the string that may have some impact on how I set the text in some cases.)

Using a method this way does not seem to set the text. Why is this?

Thanks!

public static void
  • 1,153
  • 11
  • 20

1 Answers1

1

Get the Id of the element and then do set . For example

 EditText editText=(EditText)findViewById(R.id.edittext_from_example);
 edtiText.setText("String");

Further more, if you want you can write seperate methods

it doesnt know to which editText to set the string.