Android getActionBar vs getSupportActionBar?

前端 未结 2 554
名媛妹妹
名媛妹妹 2020-12-16 03:22

Here is my code:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){

    //android.support.v7.app.ActionBar actionBar = getSupportActionBar();
           


        
2条回答
  •  借酒劲吻你
    2020-12-16 04:01

    If you are extending AppCompatActivity then you are providing backward support for older Android versions and for that you have to use getSupportActionBar().

    If you are importing android.app.ActionBar then you have to use getActionBar() and if you are importing android.support.v7.app.ActionBar then you have to use getSupportActionBar().

    Note: By using android.support.v7.app.ActionBar, you can provide backward support for older Android versions.

提交回复
热议问题