I have a simple webview client that gets the content from a url and
loads it into the WebView.  When the activity starts and the first
data is loaded into the WebView it works beautifully.  I can click the
href of the image returned in the url data and the WebView launches
the browser just fine.  However, if I then update the contents of the
WebView with another call to loadData, the WebView displays the new
data but you cannot click on anything in the WebView...

I do not see any logs like

Starting activity: Intent { action=android.intent.action.VIEW
categories={android.intent.category.BROWSABLE}
in the log viewer...

If I relaunch my activity, it again works the first time but not for
additional content.  Is there something else I am supposed to do to
get the WebView to support the clicking of hrefs in the data that was
loaded?

thanks, Mark

public class SampleWebviewClient extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button btn = (Button) findViewById(R.id.nexturl_btn);
        btn.setOnClickListener(mOnClickNextUrl);

        new Thread(mGetUrlData).start();
    }

    OnClickListener mOnClickNextUrl = new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                new Thread(mGetUrlData).start();
            }
    };

    private List<String> mQueuedUrls = new ArrayList<String>();
    private Runnable mGetUrlData = new Runnable() {
                @Override
                public void run() {
                        String data = getUrlData();
                        if (data != "") {
                                mQueuedUrls.add(data);
                                runOnUiThread(mUpdateImage);
                        }
                }
    };

    private Runnable mUpdateImage = new Runnable() {
                @Override
                public void run() {
                        WebView webView = (WebView) findViewById(R.id.webkit);
                        if (webView != null) {
                                webView.loadData(mQueuedUrls.get(0), 
"text/html", "utf-8");
                                mQueuedUrls.remove(0);
                        }
                }
    };

        public String getUrlData() {
           String data = ... get the data...
            return data;
    }
}


main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="something above"
    />
<WebView
        android:id="@+id/webkit"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
        />
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="something below"
    android:layout_weight="1"
    />
 <Button
        android:id="@+id/nexturl_btn"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="   Get Next Url   "
    />
</LinearLayout>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to