Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change text of the edit text by html

Tags:

java

How can I do that?

public class ActivityTest extends Activity {

    public EditText edtText;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test);

        WebView webView = (WebView) findViewById(R.id.webView);
        webView.loadUrl("file:///android_res/raw/htmlimages.html");
        webView.addJavascriptInterface(new MyTest(), "Scripts");
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebChromeClient(new WebChromeClient());
        edtText = (EditText) findViewById(R.id.edtText22);
like image 816
user3677549 Avatar asked May 26 '14 21:05

user3677549


2 Answers

you can use fromHtml method Like this :

String styledText = "This is <font color='red'>simple</font>.";
textView.setText(Html.fromHtml(styledText));
like image 190
Mojtaba Yeganeh Avatar answered Nov 15 '22 18:11

Mojtaba Yeganeh


In your case to change EditText call this.edtText.setText("What you want...")

like image 25
Gustavo Rozolin Avatar answered Nov 15 '22 17:11

Gustavo Rozolin