@SuppressLint("NewApi") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_navigation_drawer); mTitle = mDrawerTitle = getTitle(); mCityNames = getResources().getStringArray(R.array.drawer_items); TypedArray typedArray = getResources().obtainTypedArray(R.array.city_images); mCityImages = new int[typedArray.length()]; for (int i = 0; i < typedArray.length(); ++i) { mCityImages[i] = typedArray.getResourceId(i, 0); } typedArray.recycle(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mCityNames)); mDrawerList.setOnItemClickListener(this); // enable ActionBar app icon to behave as action to toggle nav drawer getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle( this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */) { public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } // 初始化带返回按钮的标题栏 ActionBarManager.initBackTitle(this, getActionBar(), this.getClass().getSimpleName()); }
@Override public void doBusiness(Context mContext) { // 初始化带返回按钮的标题栏 String strCenterTitle = getResources().getString(R.string.FileDownloadUploadActivity); ActionBarManager.initBackTitle(getContext(), getActionBar(), strCenterTitle); }