我一直收到这个错误:
本地类myWebClient的非法修饰符;只允许抽象或最终。
并出现此错误:
void是变量backButtonClicked的无效类型
发生错误的代码。
public class myWebClient extends WebViewClient
{
}
public void backButtonClicked(View view)
{
if (ourBrow.canGoBack())
ourBrow.goBack();
}
public void forwardButtonClicked(View view)
{
if (ourBrow.canGoForward())
ourBrow.goForward();
}
public void goButtonClicked(View view)
{
String theWebsite = Url.getText().toString();
if(theWebsite != null)
ourBrow.loadUrl(theWebsite);
}
public void refreshButtonClicked(View view)
{
ourBrow.reload();
}
答案 0 :(得分:1)
删除类的public
修饰符,并将所有方法放在类的主体中:
class myWebClient extends WebViewClient
{
public void backButtonClicked(View view)
{
if (ourBrow.canGoBack())
ourBrow.goBack();
}
public void forwardButtonClicked(View view)
{
if (ourBrow.canGoForward())
ourBrow.goForward();
}
public void goButtonClicked(View view)
{
String theWebsite = Url.getText().toString();
if(theWebsite != null)
ourBrow.loadUrl(theWebsite);
}
public void refreshButtonClicked(View view)
{
ourBrow.reload();
}
}