1. Welcome to the newer, better version of Android Forums! Be sure to see the announcement and enjoy checking it out!

    Some of you have been having login issues. - Please try now. Sorry for the trouble!
  2. All attachments uploaded on the first day of this new look need to be re-uploaded, or will appear broken. All prior to that, and all going forward, should work fine. We apologize for the inconvenience!

Set text hint problem


  1. KarneeKarnay

    KarneeKarnay Member

    I'm fairly new to Android development and I've just been going through the android development tutorials for help, but I'm stuck on this.

    [HIGH]protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
    EditText editText = (EditText) findViewById(R.id.edit_message);

    EditText.setHint(message);

    setContentView(R.layout.activity_list);
    }[/HIGH]

    My app includes a search bar. In the first activity the user types into it what they are looking for. What I am currently trying to do is try to change the text hint to the message string. This string contains what the user typed in the previous search bar. Any ideas?

    Advertisement
  2. jonbonazza

    jonbonazza Well-Known Member

    You need to use the addTextChangedListener() method of EditText to add a new TextWatcher subclass (TextWatcher is an interface, so you will need to either create a subclass and use it, or just provide an inline implementation).

Share This Page