An error (cannot resolve method) appears in the getSupportActionBar in the code below.
I wonder why.
Please let me know if you know more.
public class MainActivity extensions Activity {
private WebView myWebView;
privateEditText 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(newWebViewClient(){
@ Override
public void onPageFinished (WebView view, String url) {
getSupportActionBar().setSubtitle(view.getTitle());
urlText.setText(url);
}
});
myWebView.loadUrl(INITIAL_URL);
}
@ Override
public boolean onCreateOptionsMenu(Menu){
// Inflate the menu; this add items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@ Override
public boolean onOptionsItemSelected(MenuItem){
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, solo
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
// no inspection SimplifiableIfStatement
if(id==R.id.action_settings){
return true;
}
return super.onOptionsItemSelected(item);
}
}
getSupportActionBar()
is the method used when using the support library, so
getActionBar()
without using the support library (but minSDKVersion>=11)extendsAppCompatActivity
instead of Use one of the (although you will often end up using the latter AppCompatActivity
)
575 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
625 GDB gets version error when attempting to debug with the Presense SDK (IDE)
930 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
578 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.