-1

I want to make a some words highlighted and clickable in an EditText like it does when you misspell something. For example, if I type "flight" when I am typing, I want it to be highlighted and clickable.

Here is a snippet of the code and the XML:

Activity:

public class MainActivity extends Activity {
    EditText editText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        editText = (EditText)findViewById(R.id.textplace);
    }
}

Layout:

 <EditText
   android:id="@+id/textplace"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"/>
cyfur01
  • 3,262
  • 1
  • 34
  • 38
Unoye
  • 21
  • 4
  • No there's no such direct way to do this but if you want to open a hyperlink then yes it is possible. Check this answer http://stackoverflow.com/questions/2734270/how-do-i-make-links-in-a-textview-clickable – Apurva Jun 17 '16 at 05:38
  • what I want is to make some words the user type to be highlighted so the user can click it to lunch another screen or activity. I have some words on my mind but the problem is how to link them to Edit Text so any time the user types such words they get hyperlinked and clickable – Unoye Jun 20 '16 at 16:45

1 Answers1

0

You can use the

String str = Html.fromHtml("<a href="#>" + str + "</a>");

method to create a hyperlink on a string where text is the part of the contents of the EditText that you want linked.

Kabir Lal
  • 36
  • 2
  • what I want is to make some words the user type to be hyperlinked so the user can click it to lunch another screen or activity. I have some words on my mind but the problem is how to link them to Edit Text so any time the user types such words they get hyperlinked and clickable – Unoye Jun 20 '16 at 16:44