Reputation: 362
I'm making a WebView browser and I've made a button that will make the browser reload but it makes it crash, I'm relatively new to Android coding so i apologize if the question is noob
class myWebClient extends WebViewClient
{
public void refreshButtonClicked(View view)
{
ourBrow.reload();
}
public void goButtonClicked(View view)
{
String theWebsite = Url.getText().toString();
if(theWebsite != null)
ourBrow.loadUrl(theWebsite);
}
}
And heres the XML part with the button
<Button
android:id="@+id/bGo"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/etURL"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/go"
android:onClick="goButtonClicked" />
<Button
android:id="@+id/bRefresh"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/etURL"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@drawable/reload"
android:onClick="refreshButtonClicked" />
Upvotes: 0
Views: 143
Reputation: 1978
You don't have to create a separate class myWebClient extends WebViewClient
just put these methods in your MainActivity itself
public void refreshButtonClicked(View view)
{
ourBrow.reload();
}
public void goButtonClicked(View view)
{
String theWebsite = Url.getText().toString();
if(theWebsite != null)
ourBrow.loadUrl(theWebsite);
}
Upvotes: 1