0

i have a webview which is gets data form the previous page like this

country = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"><style type=\"text/css\">p{text-align:justify;font-size:125%;}</style></head><body>" + "<p>" + i.getStringExtra("country").toString()+"</p>"+"</body></html>";

when i try to set that to a webview web.loadData(country, "text/html", "UTF-8");

it shows plain text

when i try the following

web.loadData( URLEncoder.encode(country).replaceAll("\\+", " "), "text/html", Encoding.UTF_8.toString());

it just shows

< and nothing more

1234567
  • 2,226
  • 4
  • 24
  • 69

1 Answers1

0

Try this:

loadData(country, "text/html; charset=UTF-8", null);

Found in:

Android. WebView and loadData

Community
  • 1
  • 1
RonM
  • 187
  • 3