1

嗨,是否可以使用下面的这个 xml 文件在 android 上显示为 webview?不太确定是否有可能,或者我是否需要一个 html 文件。对不起,我不知道..

<?xml version="1.0" encoding="UTF-8" ?> 
  - <Recipes>
  - <recipe>
<category-name>Burritos</category-name> 
 <recipe-name>Pork and Bean</recipe-name> 
<recipe-description>Prepare this delicious and tasty recipe topped with protein rich ingredients. You can even use leftover meat while preparing this.</recipe-description> 
  <image>PorkAndBeanBurritos</image> 
 - <recipe-ingredients>
 - <![CDATA[ 
<li> 1 tbs olive oil </li>
<li> 500g pork loin steaks, thinly sliced </li>
<li> 1 red onion, halved, thinly sliced </li>
<li> 2 tsp sweet paprika </li>
<li> 2 tsp ground coriander </li>
<li> 1 x 400g can chopped tomatoes </li>
<li> 1 x 400g can red kidney beans, rinsed, drained </li>
<li> 2 tbs chopped fresh coriander </li>
<li> 8 flour tortillas </li>
<li> Shredded iceberg lettuce, to serve </li>
<li> Natural yoghurt, to serve</li>

]]> 
</recipe-ingredients>
- <recipe-steps>
- <![CDATA[ 
<li>Heat half the oil in a large non-stick frying pan over high heat. Add half the pork and cook, stirring, for 3 minutes or until golden. Transfer to a plate. Repeat with the remaining pork, reheating the pan between batches. </li>
<li>Heat the remaining oil in the pan. Add the onion and cook, stirring, for 2 minutes or until light golden. Add the paprika and coriander and cook, stirring, for 1 minute. Add the tomato and beans. Bring to the boil. Reduce heat to medium-high. Simmer for 3 minutes. </li>
<li>Return the pork to the pan. Simmer for 1 minute or until heated through. Remove from heat. Stir in the coriander. </li>
<li>Spoon a little of the pork mixture along the centre of each tortilla. Top with the lettuce and a dollop of yoghurt. Roll up to enclose the filling. Serve.</li>

 ]]> 
</recipe-steps>
 </recipe>

编辑:

 public class Instructions extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webview);

    WebView webview = (WebView) findViewById(R.id.myWebView);
    webview.setWebViewClient(new Instructions(this));
    webview.getSettings().setJavaScriptEnabled(true);
    webview.loadUrl("recipelistlite.xml");
}

}

4

0 回答 0