Skip to main content

How to load a xml into a webview android



I have an xml file and I want to load the xml content to a web view where the web view will be inflated to a gallery. I have parsed and able to get the parsed values, but how do I load the xml content to a web view? I have no clue about it. Please some one help me.




Comments

  1. I think you need to show content in tag,

    then parse your xml, and display webview as:

    myWebView.getSettings().setJavaScriptEnabled(true);
    myWebView.loadDataWithBaseURL(null, myPreviewContents, mime, encoding, null);

    where myPreviewContents are:

    Early in my career I took responsibility for managing people. I managed up to 250 highly trained professionals who worked as a tight-knit team. It didn’t matter that I was the youngest person in the team! For over 20 years I’ve been working with individuals and organizations to help them improve their management of people. This has ranged from military personnel to entrepreneurs, from charities to government departments. I’ve learned many secrets and tricks over these years. Some I’ve discovered for myself, but many I’ve learned from others. Humans are wonderfully inventive!

    <p>This book aims to help you improve your skills at managing people – to help you find ways in which everybody benefits. It contains 50 secrets, grouped into seven themed chapters.</p>
    <p>
    <ul>
    <li>
    <span class='pointHeading'>Build on a strong foundation.</span><span class='normalText'>You must understand what type of leader or manager you want to be. Your employer may give guidelines, but you must exert control over your day-to-day behaviour.</span>
    </li>
    <li>
    <span class='pointHeading'>Create a great team.</span><span class='normalText'>This shows how to choose the right people and quickly build a functioning team.</span>
    </li>
    <li>
    <span class='pointHeading'>Set goals and targets.</span><span class='normalText'>By setting people effective targets and goals, you can monitor progress and offer appropriate rewards.</span>
    </li>
    <li>
    <span class='pointHeading'>Motivate yourself and your people.</span><span class='normalText'>Implementing ways to motivate people is ultimately much easier than having to cajole and constantly monitor unmotivated people.</span>
    </li>
    <li>
    <span class='pointHeading'>Manage good performance.</span><span class='normalText'>You need to recognize good performance – reward it, develop it, perpetuate it and spread it to others. Otherwise you will lose your good performers and be left only with the poor ones.</span>
    </li>
    <li>
    <span class='pointHeading'>Manage poor performance.</span><span class='normalText'>Some managers find ways of managing around poor performance without tackling the poor performance itself. However, this encourages more poor performance, from both the original perpetrator and everyone else. Know how to tackle the problems head on.</span>
    </li>
    <li>
    <span class='pointHeading'>Develop your people.</span><span class='normalText'>Though often overlooked by managers, another fundamental task is developing people. You need to improve the less able, stretch and reward the able, plan succession for the future and mentor your people’s changing needs. </span>
    </li>
    </ul>
    </p>
    <p>Managing people is a hugely complex area in which you never stop learning. The secrets contained in this book will help you make massive strides towards succeeding in this fascinating role.</p>
    ]]>

    ReplyDelete
  2. A xml file is not a webpage. You have to put something like an html in loadUrl() like

    wv.loadUrl("http://www.bbc.co.uk"");


    Yes, Android uses xml files for it's UI. It inflates Views using the xml as a skeleton

    ReplyDelete
  3. You can use xsl to transform your xml, then load the resulting string into the webivew (webview.loaddata, I believe).

    See Android: Convert xml using xslt for example transforming xml.

    ReplyDelete

Post a Comment

Popular posts from this blog

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex