I created a java activity class called Capitolo8.java, I added a WebView as below but on the emulator the text is not shown except the line I set here in bold, were this code %3c%2fbr%3
isn't inserted, while works in all others classes I'm using it. I need to create a list of terms and book's reference lines. How can I handle this?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:orientation="vertical"
android:layout_height="wrap_content">
<RelativeLayout android:id="@+id/relativeLayout3"
android:layout_width="match_parent" android:layout_height="25dip">
<TextView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#FFCC00"
android:gravity="center"
android:paddingLeft="6dip"
android:text="@string/bottone_cap8"
android:textColor="#000000"
android:textStyle="bold" />
</RelativeLayout>
<ScrollView android:id="@+id/scrollView2"
android:background="#E5E5C9" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout android:layout_width="fill_parent"
android:id="@+id/linearLayout2" android:layout_height="match_parent">
<WebView
android:id="@+id/webview3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="fill_horizontal"
android:paddingLeft="6dip"
android:paddingRight="4dip"
android:textColor="#000000"
android:textSize="18dip" />
<TextView
android:id="@+id/textView40"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@id/webview3"
android:background="#FFCC00"
android:gravity="center"
android:paddingLeft="6dip"
android:text="@string/bottone_bibliografia"
android:textColor="#000000"
android:textStyle="bold" />
<WebView
android:id="@+id/webview2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textView40"
android:clickable="false"
android:gravity="fill_horizontal"
android:paddingLeft="6dip"
android:paddingRight="4dip"
android:textColor="#000000"
android:textSize="18dip" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@android:dimen/app_icon_size"
android:layout_below="@id/webview2"
android:layout_marginTop="@dimen/pulsantinavigazione"
android:orientation="horizontal">
<TextView
android:id="@+id/textView28"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:clickable="true"
android:gravity="start|center_vertical"
android:minHeight="48dp"
android:paddingLeft="@dimen/copyright"
android:text="@string/bottone_cap7"
android:textColor="@color/dividerwoc"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
</LinearLayout>
package com.wocmultimedia.MaguareIT;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.webkit.WebView;
import android.widget.TextView;
public class Capitolo8 extends Activity{
WebView mWebView;
WebView pWebView;
WebView tWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.capitolo8);
tWebView = (WebView) findViewById(R.id.webview3);
String text3 = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;
charset=UTF-8\"></head><body>" + "<p align=\"justify\">" +
getString(R.string.testo_capitolo8) + "</p> "
+ "</body></html>";
tWebView.loadData(text3, "text/html", "utf-8");
mWebView = (WebView) findViewById(R.id.webview2);
String text2 = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;
charset=UTF-8\"></head><body>" + "<p align=\"justify\">" +
getString(R.string.testo_capitolo8b) + "</p> "
+ "</body></html>";
mWebView.loadData(text2, "text/html", "utf-8");
TextView bnt = (TextView) findViewById(R.id.textView28);
bnt.setOnClickListener(v -> {
Intent i = new Intent (v.getContext(), Capitolo7.class);
v.getContext().startActivity(i);});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
if (item.getItemId() == R.id.delfino) {
Intent g = new Intent(this, Main.class);
startActivity(g);
return true;}
else if (item.getItemId() == R.id.indice) {
Intent l = new Intent(this, IndiceLibro.class);
startActivity(l);
return true;}
else {
return super.onOptionsItemSelected(item);
}
}
}
This is the string.xml part related to the above code
<string name="testo_capitolo8" formatted="false">**GLOSSARIO**%3c%2fbr%3Ashaninka
%3c%2fbr%3Abiro. Ciao
%3c%2fbr%3Aldea. Un gruppo di capanne appartenente ad una famiglia
%3c%2fbr%3Jonkari. Antara, flauto di canna a più ance (Selva Central)
%3c%2fbr%3Kametsa. Benvenuto, va bene
%3c%2fbr%3Masato. Bevanda tipica a base di cassava e patata dolce
%3c%2fbr%3Masatiáda. Bevuta collettiva di masato
%3c%2fbr%3Mashonki. Quena transversa o flauto di canna traverso
%3c%2fbr%3Pajo. Recipiente ricavato dal frutto della pianta di tutumo
%3c%2fbr%3Pasonki. Grazie
%3c%2fbr%3Piarentsi. Masato
%3c%2fbr%3Shobirentsi. Quena
%3c%2fbr%3Sonkare. Antara (area di Pichis, Tambo, Urubamba)
%3c%2fbr%3Tamporo. Tamburo
%3c%2fbr%3%3c%2fbr%3Yanesha
%3c%2fbr%3Chomoch. Colibrì
%3c%2fbr%3Con. Tamburo
%3c%2fbr%3Masheñ. Fratello
%3c%2fbr%3Pallot. Quena, flauto di canna senza boccaglio a 7 fori
%3c%2fbr%3Penquëll o Pencoll. Simile al pallot ma più lunga e sottile
%3c%2fbr%3Parasyos. Grazie
%3c%2fbr%3Puetare. Buongiorno
%3c%2fbr%3Requërcanets. Antara, zampogna di canna a 5 ance
%3c%2fbr%3Tsapo. Buona sera, buona notte
</string>
<string name="testo_capitolo8b" formatted="false">BIBLIOGRAFIA
%3c%2fbr%3Giammarresi, A. 2020. Mapiniki: Storia Interattiva della Nostra Comunità Ashaninka-Yanesha, Cilavegna: Angelo Giammarresi, World On Communications.
%3c%2fbr%3https://es.wikipedia.org/wiki/Astrocaryum_aculeatum
%3c%2fbr%3https://en.wikipedia.org/wiki/Astrocaryum_chambira
%3c%2fbr%3http://demo.madexo.pe/wp-content/uploads/2017/11/MADEXO_MADERA-TORNILLO.pdf
%3c%2fbr%3https://en.wikipedia.org/wiki/Cedrelinga
%3c%2fbr%3http://www.tropicaltimber.info/specie/cedrorana-cedrelinga-cateniformis/
%3c%2fbr%3https://es.wikipedia.org/wiki/Juglans_neotropica
%3c%2fbr%3https://maderaliaperu.com/especies-madera/nogal-peruano-madera/
%3c%2fbr%3https://es.wikipedia.org/wiki/Distrito_de_Pebas
%3c%2fbr%3https://www.monografias.com/trabajos62/especies-forestales-selva-peruana/especies-forestales-selva-peruana3.shtml
%3c%2fbr%3https://en.wikipedia.org/wiki/Aniba_rosaeodora
%3c%2fbr%3https://www.monografias.com/trabajos62/especies-forestales-selva-peruana/especies-forestales-selva-peruana3.shtml
%3c%2fbr%3https://www.fundacionbat.com.co/instrumentos.php?IDTipoInstrumento=1
%3c%2fbr%3https://en.wikipedia.org/wiki/Endlicheria
%3c%2fbr%3https://www.gbif.org/species/4180762
%3c%2fbr%3https://loveyourplanet.com/doc/aniba_panurensis
</string>`
I solved using 2 TextView instead of the 2 WebView because there was no need for special formatting. So I replaced the %3c%2fbr%3 with a \n and it works fine for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.