sco1385
شنبه 24 خرداد 1393, 18:01 عصر
من این کد را در وبویو قرار دادم تا با زدن دکمه بک به صفحه قبلی بازگردم:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// Check if the key event was the Back button and if there's history
if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView.canGoBack()) {
myWebView.goBack();
return true;
}
// If it wasn't the Back key or there's no web page history, bubble up to the default
// system behavior (probably exit the activity)
return super.onKeyDown(keyCode, event);
}
این کد گویا تنها در اکتیویتی کار میکند، چون وقتی آن را در یک فرگمنت قرار دادم روی onKeyDown اخطار میدهد:
The method onKeyDown(int, KeyEvent) is undefined for the type Fragment
من از تمپلیت نوهگیشن دراور استفاده میکنم.
چه تغییری در کد ایجاد کنم؟
ممنون
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// Check if the key event was the Back button and if there's history
if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView.canGoBack()) {
myWebView.goBack();
return true;
}
// If it wasn't the Back key or there's no web page history, bubble up to the default
// system behavior (probably exit the activity)
return super.onKeyDown(keyCode, event);
}
این کد گویا تنها در اکتیویتی کار میکند، چون وقتی آن را در یک فرگمنت قرار دادم روی onKeyDown اخطار میدهد:
The method onKeyDown(int, KeyEvent) is undefined for the type Fragment
من از تمپلیت نوهگیشن دراور استفاده میکنم.
چه تغییری در کد ایجاد کنم؟
ممنون