Android webview变黑了

时间:2014-01-08 14:07:23

标签: android listview webview

爵士

我将使用viewholder模式实现listvieww以显示Web内容。在实现方面,某些设备变为黑色,如下所示。我有什么方法可以采取警告或修改以防止此类问题?

ScreenShot

以下是我的代码

@Override
    public View getView(int position, View v, ViewGroup parent) {
        // Keeps reference to avoid future findViewById()
        ContactsViewHolder viewHolder;

        if (v == null) {
            LayoutInflater li = (LayoutInflater) getContext().getSystemService(
                    Context.LAYOUT_INFLATER_SERVICE);
            v = li.inflate(R.layout.readpost_reply, parent, false);
            viewHolder = new ContactsViewHolder();
            viewHolder.txName = (TextView) v.findViewById(R.id.userName);

            //
            viewHolder.txContent = (WebView) v.findViewById(R.id.replycontent);
            //
            WebSettings settings = viewHolder.txContent.getSettings();
            settings.setDefaultTextEncodingName("utf-8");

            settings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
            viewHolder.txContent.setFocusable(false);
            viewHolder.txContent.setClickable(true);
            viewHolder.txContent.setBackgroundColor(Color.parseColor("#00FFFFFF"));


            viewHolder.txTime = (TextView) v.findViewById(R.id.replytime); 
            viewHolder.ivQuote = (ImageView) v.findViewById(R.id.action_quote);
            v.setTag(viewHolder);
        } else {
            viewHolder = (ContactsViewHolder) v.getTag();
        }

        final Content content = (Content) contacts.get(position);
        if (content != null) {
            viewHolder.txName.setText(content.getUsername());
            //  viewHolder.txEmails.setText(content.getContent());
            TextProcessor processor = BBProcessorFactory.getInstance().create();
            String htmlParsed = processor.process(content.getContent());
            for(int i = 0 ; i < hkgiconsCodes.length ; i++){
                htmlParsed = bbC.replace(htmlParsed, hkgiconsCodes[i], hkgiconsHTML[i]);
            }

            for(int i = 0 ; i < otherCodes.length ; i++){
                htmlParsed = bbC.replace(htmlParsed, otherCodes[i], otherHTML[i]);
            }
            htmlParsed =   bbC.replaceColor(htmlParsed, true);
            htmlParsed =   bbC.replaceColor(htmlParsed, false);


  System.out.println(htmlPreffix + htmlParsed + htmlSuffixString);
            viewHolder.txContent.loadDataWithBaseURL(null, htmlPreffix + htmlParsed + htmlSuffixString, "text/html", "utf-8", null);
            viewHolder.txTime.setText(content.getTime());

            viewHolder.txName.setTextColor(Color.BLACK);
            //viewHolder.txEmails.setTextColor(Color.BLACK);
            //          viewHolder.txTime.setTextColor(Color.BLACK);

            if(content.getSex().equals("male")){
                viewHolder.txName.setTextColor(Color.BLUE);
            }else{
                viewHolder.txName.setTextColor(Color.RED);
            }
...


    static class ContactsViewHolder {
        TextView txName;
        WebView txContent;
        TextView txTime;
        ImageView ivQuote;
    }

即使我评论了

viewHolder.txContent.setBackgroundColor(Color.parseColor("#00FFFFFF"));

并将颜色设置为与透明相同,黑色屏幕仍然出现在Sony设备

0 个答案:

没有答案