0

问题很简单,当我有来自 HoloEverywhere 库(import org.holoeverywhere.app.Activity;)的活动时,webview 不起作用,并且当我使用相同的活动,使用相同的代码,但导入默认活动(import android.app.Activity;)时,webview 再次工作。

这是使用 webview 工作的一项活动的示例:

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;


public class Bienvenida extends Activity{

    TextView welcome;
    Button ok;

    //justificacion
    WebView mWebView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.bienvenida_layout);

        //justificacion
        mWebView = (WebView) findViewById(R.id.webview);

        WebSettings settings = mWebView.getSettings();
        settings.setDefaultTextEncodingName("utf-8");
        mWebView.loadUrl("file:///android_asset/letraperson.html");
        mWebView.setBackgroundColor(0x00000000);
        mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);




        ok= (Button)findViewById(R.id.btOK);
        welcome=(TextView)findViewById(R.id.tvQuerido_lector);
        Typeface person = Typeface.createFromAsset(getAssets(), "letrapaa.ttf");

        String button = new String(ok.getText().toString());
        ok.setText(button, TextView.BufferType.SPANNABLE);
        SpannableString okee = (SpannableString) ok.getText();
        okee.setSpan(new ForegroundColorSpan(Color.rgb(204, 0, 0)), 0, 1, 0);

        //TextView person:...
        String user = new String (welcome.getText().toString());
        welcome.setText( user, TextView.BufferType.SPANNABLE );
        SpannableString s = (SpannableString)welcome.getText();
        s.setSpan(new ForegroundColorSpan(Color.rgb(204, 0, 0)), 0, 1, 0);



        welcome.setTypeface(person);
        ok.setTypeface(person);

        ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent intent = new Intent("CREARUSUARIO_CAMPAYO");
                startActivity(intent);
                finish();
            }
        });
    }

}

但是,如果我想自定义该活动以在 2.1+ 手机上使用全息主题,我需要从org.holoeverywhere.app.Activity改为扩展该活动android.app.Activity

所以......当我从 HoloEverywhere 库扩展活动时,会发生以下情况:

a)如果我在该活动中没有 webview,则一切正常。

b)如果我在该活动中有一个 webview,则该活动不起作用。

然后我必须在拥有 Holo 主题或拥有 webview 之间进行选择(例如,我可以在其中证明文本的合理性,而 Textview 无法做到这一点)

有谁知道如何在 HoloEverywhere 的一项活动中使用 webview?

4

0 回答 0