0

我将 html 字符串插入数据库。然后我在 webview 中加载该字符串,它只显示null。请帮我。这是我的代码:

public class MainActivity extends Activity {
     WebView browser;
    private static String inp;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

         browser=(WebView)findViewById(R.id.w1);


         // browser.loadDataWithBaseURL("x-data://base",inp,"text/html", "UTF-8",null);
         browser.loadData(inp, "text/html", "UTF-8"); 



    }
    public void insertUndergraduate(){
        AndroidOpenDbHelper androidOpenDbHelperObj = new AndroidOpenDbHelper(this);
        SQLiteDatabase sqliteDatabase = androidOpenDbHelperObj.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        inp = "<html>"+"<body><h1>hai mohan</h1></body>"+"</html>";
        contentValues.put(AndroidOpenDbHelper.COLUMN_NAME_PAGE,inp);

    }
}
4

1 回答 1

0

inp你之前没有设置browser.loadData(inp, "text/html", "UTF-8");

于 2013-03-30T02:00:58.527 回答