androidのgetSupportActionBarのエラー
下記のコードのgetSupportActionBarのところにエラー(cannot resolve method)が出てしまいます。
何故でしょうか。
詳しい方、ご教示ください。
public class MainActivity extends Activity {
private WebView myWebView;
private EditText urlText;
private static final String INITIAL_URL = "http://doctormouse.me/";
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myWebView = (WebView) findViewById(R.id.myWebView);
urlText = (EditText) findViewById(R.id.urlText);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
getSupportActionBar().setSubtitle(view.getTitle());
urlText.setText(url);
}
});
myWebView.loadUrl(INITIAL_URL);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}