简体   繁体   English

我在模拟器上得到不完整的文本,但 logcat 没有显示错误

[英]I get incomplete text on the emulator but logcat doesn't show an error

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.我创建了一个名为 Capitolo8.java 的 java 活动 class,我添加了一个 WebView,如下所示,但在模拟器上,除了我在此处设置为粗体的行外,没有显示文本,是否未插入此代码%3c%2fbr%3 ,而适用于我正在使用的所有其他课程。 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.xml部分

<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>`

This is the screenshot of emulator这是模拟器的截图截图模拟器

I solved using 2 TextView instead of the 2 WebView because there was no need for special formatting.我使用 2 TextView 而不是 2 WebView 解决了问题,因为不需要特殊格式。 So I replaced the %3c%2fbr%3 with a \n and it works fine for me.所以我用 \n 替换了 %3c%2fbr%3 ,它对我来说很好用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM