i get the following error in my gradle console. Tried looking for the deprecated API but couldn't find it. Thanks in advance!!!
Error:
DemoActivity.java uses or overrides a deprecated API. Note: Recompile with
-Xlint:deprecation for details.
public class BaseActivity extends ActionBarActivity {
private static final String TAG = "DemoActivity";
DrawerLayout mDrawerlDrawerLayout;
FrameLayout actContent;
private LinearLayout linear;
private ActionBarDrawerToggle actionBarToggle;
private Toolbar toolbar;
private ImageView mImageView;
private int height;
private SlidingUpPanelLayout mSlidingUpPanelLayout;
private ListView drawerListView;
private ArrayAdapter<String> navigationDrawerAdapter;
private String[] drawerItem = {"Email", "Wink", "Favourite", "Match me", "About"};
@Override
public void setContentView(final int layoutResID) {
// TODO Auto-generated method stub
linear = (LinearLayout) getLayoutInflater().inflate(R.layout.base_activity, null);
actContent = (FrameLayout) linear.findViewById(R.id.frame_container);
mDrawerlDrawerLayout = (DrawerLayout) linear.findViewById(R.id.drawer_layout);
// set the drawer layout as base_activity content view of Activity.
toolbar = (Toolbar) linear.findViewById(R.id.main_toolbar);
setSupportActionBar((Toolbar) linear.findViewById(R.id.main_toolbar));
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return true;
}
});
// Inflate a menu to be displayed in the toolbar
toolbar.inflateMenu(R.menu.demo);
//toolbar.getBackground().setAlpha(0);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false);
setContentView(linear);
// add layout of BaseActivities inside framelayout.i.e. frame_container
getLayoutInflater().inflate(layoutResID, actContent, true);
initDrawerView();
initDrawer();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.demo, menu);
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
return super.onPrepareOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Log.e("Drawer", "clicked");
if (actionBarToggle.onOptionsItemSelected(item)) {
Log.e("Drawer item clicked", "clicked");
return true;
}
if (item.getItemId() == android.R.id.home) {
Log.e("Drawer item clicked item id", "clicked");
try {
if (mDrawerlDrawerLayout.isDrawerOpen(drawerListView)) {
mDrawerlDrawerLayout.closeDrawer(drawerListView);
} else {
mDrawerlDrawerLayout.openDrawer(drawerListView);
}
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
switch (item.getItemId()) {
case R.id.action_search: {
return true;
}
case R.id.action_settings: {
return true;
}
}
return super.onOptionsItemSelected(item);
}
private void initDrawerView() {
drawerListView = (ListView) findViewById(R.id.list_slidermenu);
mDrawerlDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
navigationDrawerAdapter = new ArrayAdapter<String>(BaseActivity.this,
android.R.layout.simple_list_item_1, drawerItem);
drawerListView.setAdapter(navigationDrawerAdapter);
drawerListView.setOnItemClickListener(new DrawerItemClickListener());
}
private void initDrawer() {
actionBarToggle = new ActionBarDrawerToggle(BaseActivity.this, mDrawerlDrawerLayout, toolbar,
R.string.open_drawer, R.string.close_drawer) {
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
}
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
}
};
mDrawerlDrawerLayout.setDrawerListener(actionBarToggle);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
actionBarToggle.syncState();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
actionBarToggle.onConfigurationChanged(newConfig);
}
private class DrawerItemClickListener implements ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
try {
Log.e("Drawer item click", "click");
mDrawerlDrawerLayout.closeDrawers();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…