android - ActionBarActivity is deprecated Eclipse -


this question has answer here:

i new android-programming. installed sdk , added library , when create new project error:

actionbaractivity deprecated

i use android support library 22.2 , android 5.1.1(api 22).

package com.example.ww;  import android.support.v7.app.actionbaractivity;//problem import android.os.bundle; import android.view.menu; import android.view.menuitem;   public class mainactivity extends actionbaractivity { //problem      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);     }      @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.main, menu);         return true;     }      @override     public boolean onoptionsitemselected(menuitem item) {         // handle action bar item clicks here. action bar         // automatically handle clicks on home/up button, long         // specify parent activity in androidmanifest.xml.         int id = item.getitemid();         if (id == r.id.action_settings) {             return true;         }         return super.onoptionsitemselected(item);     } } 

replace actionbaractivity appcompatactivity.

you don't need anything, because it's deprecated doesn't mean it's not functional. means not supported in future. eclipse should giving warning, not error.

here's current souce code of actionbaractivity, the android source code:

/**  * @deprecated use {@link android.support.v7.app.appcompatactivity} instead.  */ @deprecated public class actionbaractivity extends appcompatactivity { } 

to clarify, need replace

public class mainactivity extends actionbaractivity { 

with

public class mainactivity extends appcompatactivity { 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -