List of usage examples for android.widget ArrayAdapter ArrayAdapter
public ArrayAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List<T> objects)
From source file:com.df.app.carCheck.VehicleInfoLayout.java
/** * edit// w w w . j av a 2 s . c o m */ private void setCountryEdit() { final ArrayAdapter<String> adapter; if (vehicleModel == null) { adapter = new ArrayAdapter<String>(rootView.getContext(), android.R.layout.simple_list_item_1, Helper.getEmptyStringList()); } else { adapter = new ArrayAdapter<String>(rootView.getContext(), android.R.layout.simple_list_item_1, vehicleModel.getCountryNames()); } countryEdit.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { showListDialog(R.string.chooseCountry, adapter, new Handler(new Handler.Callback() { @Override public boolean handleMessage(Message message) { if (message.what == 0) { countryEdit.setText(""); brandEdit.setText(""); manufacturerEdit.setText(""); seriesEdit.setText(""); modelEdit.setText(""); } else { Country country = vehicleModel.getCountries().get(message.what - 1); countryEdit.setText(country.name); // ??edit if (lastCountryIndex != message.what) { brandEdit.setText(""); manufacturerEdit.setText(""); seriesEdit.setText(""); modelEdit.setText(""); } setBrandEdit(country); } lastCountryIndex = message.what; return true; } })); } }); }
From source file:com.example.gemswin.screencastrecevertest.MainActivity_Reciever.java
protected void DoubtBox1 () { // TODO Auto-generated method stub dialogDoubt1 = new Dialog(MainActivity_Reciever.this); dialogDoubt1.requestWindowFeature(Window.FEATURE_NO_TITLE); dialogDoubt1.setContentView(R.layout.activity_doubtlist_reciever); //here mainListView = (ListView)dialogDoubt1.findViewById(R.id.mainListView); //list ki shuruat /*String[] planets = new String[] { "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"}; planetList.addAll( Arrays.asList(planets) );*/ // Create ArrayAdapter using the planet list. listAdapter = new ArrayAdapter<String>(MainActivity_Reciever.this, R.layout.simplerow_reciever, planetList); mainListView.setAdapter(listAdapter); mainListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int pos, long id) { // TODO Auto-generated method stub itemValue = (String) mainListView.getItemAtPosition(pos); DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override//from w w w. j a v a 2s .c om public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: new delete().execute(); break; case DialogInterface.BUTTON_NEGATIVE: //No button clicked break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(arg1.getContext()); builder.setMessage("Are you sure to delete this doubt ?").setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); return true; } }); dialogDoubt1.show(); }
From source file:com.microsoft.o365_android_onenote_rest.SnippetDetailFragment.java
private void populateSpinner(String[] strings) { ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<>(getActivity(), simple_spinner_item, strings); spinnerArrayAdapter.setDropDownViewResource(simple_spinner_dropdown_item); mSpinner.setAdapter(spinnerArrayAdapter); }
From source file:com.hybris.mobile.app.commerce.fragment.CheckoutFragmentBase.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mPlaceOrderButton = (Button) view.findViewById(R.id.checkout_place_order_button); mTermsConditionsLayout = (LinearLayout) view.findViewById(R.id.checkout_terms_conditions_layout); mTermsConditionsText = (TextView) view.findViewById(R.id.checkout_terms_conditions_text); mTermsConditionsCheckbox = (CheckBox) view.findViewById(R.id.checkout_terms_conditions_checkbox); mToolTip = new ToolTip(getActivity(), getString(R.string.checkout_payment_number_button_description, getString(R.string.name_storefront))); mPlacingOrderErrorMsgLayout = (LinearLayout) view .findViewById(R.id.checkout_placing_order_error_msg_layout); mTermsConditionsErroMsgLayout = (LinearLayout) view .findViewById(R.id.checkout_terms_conditions_error_msg_layout); mDeliveryAddressAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, new ArrayList<String>()); mDeliveryMethodAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, new ArrayList<String>()); mDeliveryAddressSpinner = (Spinner) view.findViewById(R.id.checkout_delivery_address_spinner); mDeliveryMethodSpinner = (Spinner) view.findViewById(R.id.checkout_delivery_method_spinner); // Listeners//from ww w .j av a2 s . c o m mTermsConditionsText.setOnClickListener(mTermsConditionsTextListener); mToolTip.setOnClickListener(mTooltipListener); mPlaceOrderButton.setOnClickListener(mPlaceOrderButtonListener); initDeliveryAddressSpinner(); initDeliveryMethodSpinner(); // Disable all spinners except the payment type and cost center mDeliveryAddressSpinner.setClickable(false); mDeliveryMethodSpinner.setClickable(false); // Restore the current spinner selection if (savedInstanceState != null) { if (savedInstanceState.containsKey(SAVED_INSTANCE_DELIVERY_METHOD)) { indexSelectedDeliveryMethod = savedInstanceState.getInt(SAVED_INSTANCE_DELIVERY_METHOD, 0); } if (savedInstanceState.containsKey(SAVED_INSTANCE_DELIVERY_ADDRESS)) { indexSelectedDeliveryAddress = savedInstanceState.getInt(SAVED_INSTANCE_DELIVERY_ADDRESS, 0); } } }
From source file:com.cybussolutions.wikki.afri_pay.SignUp.java
@SuppressLint("NewApi") @Override//from ww w .ja v a 2 s. c om protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sign_up); this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); android.support.v7.app.ActionBar ab = getSupportActionBar(); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Enable the Up button if (ab != null) { ab.setHomeAsUpIndicator(R.drawable.ic_back); ab.setDisplayHomeAsUpEnabled(true); ab.setTitle("Registration"); } // BugSenseHandler.initAndStartSession(this, "1c9ce82c"); // chromeHelpPopup = new ChromeHelpPopup(SignUp.this, "Password should contain capital and small alphabets, one number and one special character. Example: Cybus@12"); // SelectedDateView = (TextView) findViewById(R.id.DatePickerInput); // imageView=(ImageView)findViewById(R.id.signup_imageView); firstname = (EditText) findViewById(R.id.signup_firstName); lastname = (EditText) findViewById(R.id.signup_lastName); email = (EditText) findViewById(R.id.signup_email); mobile = (EditText) findViewById(R.id.signup_mobile); gender = (RadioGroup) findViewById(R.id.genderRG); gender.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.mrRB: { genderText = "Male"; title = "Mr"; break; } case R.id.missRB: { genderText = "Female"; title = "Miss"; break; } case R.id.mrsRB: { genderText = "Female"; title = "Mrs"; break; } default: { break; } } } }); // idNo=(EditText) findViewById(R.id.signup_idNum); /* buttonchoose=(Button) findViewById(R.id.uploadimage); buttonchoose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // openGallery(v); } });*/ try { Button b = (Button) findViewById(R.id.signup_register); if (b != null) { b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub submit(v); } }); } Button cancel = (Button) findViewById(R.id.signup_cancel); if (cancel != null) { cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { finish(); } }); } } catch (Exception e) { e.printStackTrace(); } /* doctype=(RadioGroup) findViewById(R.id.signup_doctype); doctype.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.signup_passport: value = "Passport"; typeid="5"; break; case R.id.signup_license: value = "Driving License"; typeid="4"; break; } } });*/ String COmpare = "United Kingdom"; CountriesObjects = new ArrayList<>(); CountriesName = new ArrayList<>(); DataBase DataBase = new DataBase(SignUp.this); CountriesObjects = DataBase.getCountriesDB(""); for (int i = 0; i < CountriesObjects.size(); i++) { CountriesName.add(CountriesObjects.get(i).getCountry_name()); } country = (Spinner) findViewById(R.id.signup_countries_spinner); ArrayAdapter adapter201 = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, CountriesName); country.setAdapter(adapter201); if (!COmpare.equals(null)) { int spinnerPosition = adapter201.getPosition(COmpare); country.setSelection(spinnerPosition); } country.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub // InputMethodManager inputMethodManager = (InputMethodManager) // getSystemService(Activity.INPUT_METHOD_SERVICE); // inputMethodManager.hideSoftInputFromWindow(getCurrentFocus() // .getWindowToken(), 0); return false; } }); country.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int pos, long arg3) { // TODO Auto-generated method stub countrycode = (TextView) findViewById(R.id.signup_code); countrycode.setText("+" + CountriesObjects.get(pos).getCalling_code()); countrycode.setEnabled(false); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); // user_name = (EditText) findViewById(R.id.signup_userName); password = (EditText) findViewById(R.id.signup_password); re_password = (EditText) findViewById(R.id.signup_confirmpassword); re_password.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub EditText e = (EditText) findViewById(R.id.signup_password); String pass = e.getText().toString(); TextView d = (TextView) findViewById(R.id.matchPassword); if (!pass.contentEquals(s)) { d.setText("Passwords Do not Match"); d.setVisibility(View.VISIBLE); } else { d.setVisibility(View.GONE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); }
From source file:com.cssweb.android.trade.stock.StockTrading.java
@Override public void onCreate(Bundle paramBundle) { super.onCreate(paramBundle); sc = new ServiceControl(this);//?? ///*from w ww .j a v a 2s . c o m*/ HandlerThread mHandlerThread = new HandlerThread("CSSWEB_THREAD"); mHandlerThread.start(); priceHandler = new PriceDataHandler(mHandlerThread.getLooper()); setContentView(com.cssweb.android.main.R.layout.zr_trade_stock_trade); Bundle bundle = getIntent().getExtras(); type = bundle.getInt("type"); bsname = bundle.getString("bsname"); String stockCode = bundle.getString("stkcode"); initTitle(R.drawable.njzq_title_left_back, 0, bsname); LinearLayout localLinearLayout = (LinearLayout) findViewById(R.id.zrtradelayout); localLinearLayout.setOnFocusChangeListener(setOnEditFocusListener); this.m_vklayout = localLinearLayout; View localView1 = this.m_vklayout; localView1.setOnFocusChangeListener(setOnEditFocusListener); View localView2 = this.m_vklayout; localView2.setOnClickListener(setOnEditClickListener); viewFlipper = (ViewFlipper) this.findViewById(R.id.ViewFlipper01); preView = (ImageView) findViewById(R.id.previous_screen); leftIn = AnimationUtils.loadAnimation(this, R.anim.push_left_in_layout); leftOut = AnimationUtils.loadAnimation(this, R.anim.push_left_out_layout); rightIn = AnimationUtils.loadAnimation(this, R.anim.push_right_in_layout); rightOut = AnimationUtils.loadAnimation(this, R.anim.push_right_out_layout); priceView = (PriceMini) findViewById(R.id.zrviewprice); trendView = (TrendView) findViewById(R.id.zrviewtrend); trendView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return gestureDetector.onTouchEvent(event); } }); klineView = (KlineMini) findViewById(R.id.zrviewkline); klineView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return gestureDetector.onTouchEvent(event); } }); financeView = (FinanceMini) findViewById(R.id.zrviewfinance); stockHolder = (Spinner) findViewById(R.id.zrtxtaccount); queryMethod = (Spinner) findViewById(R.id.zrtxtbsflag); // availableNum = (SeekBar) findViewById(R.id.zrcanbs); // lblMaxNumber = (TextView)findViewById(R.id.txtMaxNumber); stkcode = (EditText) findViewById(R.id.zredtstockcode); stkname = (TextView) findViewById(R.id.zrtxtstockname); price = (EditText) findViewById(R.id.zredtprice); number = (EditText) findViewById(R.id.zredtcount); lblNumberUnit = (TextView) findViewById(R.id.lblNumberUnit); btn0 = (ShadowButton) findViewById(R.id.zr_surebutton); btn0.setOnClickListener(myShowProgreeBar); layoutprice0 = (LinearLayout) findViewById(R.id.LinearLayout03); layoutprice = (LinearLayout) findViewById(R.id.LinearLayout11); //layoutAvaiNumber = (LinearLayout)findViewById(R.id.LinearLayout04); //layoutAvaiAsset = (LinearLayout)findViewById(R.id.LinearLayout06); lblAvaiAsset = (TextView) findViewById(R.id.lblAvaiAsset); AvaiAsset = (TextView) findViewById(R.id.AvaiAsset); lblPrice = (TextView) findViewById(R.id.lblPrice); lblPrice1 = (TextView) findViewById(R.id.lblPrice1); lblNumber = (TextView) findViewById(R.id.lblNumber); avaiAsset = (TextView) findViewById(R.id.AvaiAsset); lblNumberUnit = (TextView) findViewById(R.id.lblNumberUnit); setDynamic(); adjustDownPrice = (ImageView) findViewById(R.id.AdjustDownPrice); adjustDownPrice.setTag(0); adjustDownPrice.setOnClickListener(adjustIconListener); adjustUpPrice = (ImageView) findViewById(R.id.AdjustUpPrice); adjustUpPrice.setTag(1); adjustUpPrice.setOnClickListener(adjustIconListener); adjustDownNumber = (ImageView) findViewById(R.id.AdjustDownNumber); adjustDownNumber.setTag(2); adjustDownNumber.setOnClickListener(adjustIconListener); adjustUpNumber = (ImageView) findViewById(R.id.AdjustUpNumber); adjustUpNumber.setTag(3); adjustUpNumber.setOnClickListener(adjustIconListener); stkcode.setText(stockCode); if (stkcode.getText().length() == 6) { showProgress(); } stkcode.setInputType(InputType.TYPE_NULL); stkcode.setFocusable(true); stkcode.setTag("STOCK"); stkcode.setOnClickListener(setOnEditClickListener); stkcode.setOnFocusChangeListener(setOnEditFocusListener); price.setInputType(InputType.TYPE_NULL); price.setFocusable(true); price.setTag("NUMDOT"); price.setOnClickListener(setOnEditClickListener); price.setOnFocusChangeListener(setOnEditFocusListener); number.setInputType(InputType.TYPE_NULL); number.setFocusable(true); number.setTag(""); number.setOnClickListener(setOnEditClickListener); number.setOnFocusChangeListener(setOnEditFocusListener); stkcode.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable arg0) { //queryStock(queryCode.getText()); OnTextChanged(arg0); } public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); holder = TradeUser.getInstance().getHolder(); stockHolderAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, (String[]) holder.toArray(new String[holder.size()])); stockHolderAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); stockHolder.setAdapter(stockHolderAdapter); String[] arrayOfString = getResources().getStringArray(R.array.other_market_bs_methods); for (int i = 0; i < arrayOfString.length; i++) { Log.e("arrayOfString", arrayOfString[i]); } queryMethodAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, arrayOfString); queryMethodAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); queryMethod.setAdapter(queryMethodAdapter); queryMethod.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position != 0) { layoutprice0.setVisibility(View.GONE); layoutprice.setVisibility(View.VISIBLE); } else { layoutprice0.setVisibility(View.VISIBLE); layoutprice.setVisibility(View.GONE); } } public void onNothingSelected(AdapterView<?> arg0) { } }); int h = R.drawable.forminput; Resources localResources = getResources(); Drawable localDrawable = null; localDrawable = localResources.getDrawable(h); int spinnerheight = localDrawable.getIntrinsicHeight() - 4; // Log.e("<<<<<<<<<<<<<<<<<<<eeeeeeeeeeeeeeeeeeeeeeeeeee>>>>>>>>>>>>>>", String.valueOf(spinnerheight)); LinearLayout.LayoutParams linearParams1 = (LinearLayout.LayoutParams) stockHolder.getLayoutParams();//?stockHolder? linearParams1.height = spinnerheight;//?? stockHolder.setLayoutParams(linearParams1); LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) queryMethod.getLayoutParams();//?queryMethod? linearParams.height = spinnerheight;//?? queryMethod.setLayoutParams(linearParams); }
From source file:com.github.vseguip.sweet.contacts.SweetConflictResolveActivity.java
/** * @param fieldTable//from w ww .j a v a 2s . c o m * @param nameOfField * @param field */ private void addConflictRow(TableLayout fieldTable, final String nameOfField, final String fieldLocal, final String fieldRemote) { if (mCurrentLocal == null || mCurrentSugar == null) return; // String fieldLocal = mCurrentLocal.get(nameOfField); // String fieldRemote = mCurrentSugar.get(nameOfField); TableRow row = new TableRow(this); final Spinner sourceSelect = new Spinner(this); sourceSelect.setBackgroundResource(R.drawable.black_underline); ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, this.getResources().getStringArray(R.array.conflict_sources)); spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sourceSelect.setAdapter(spinnerArrayAdapter); // Open the spinner when pressing any of the text fields OnClickListener spinnerOpener = new OnClickListener() { @Override public void onClick(View v) { sourceSelect.performClick(); } }; row.addView(sourceSelect); fieldTable.addView(row); row = new TableRow(this); TextView fieldName = new TextView(this); int stringId = this.getResources().getIdentifier(nameOfField, "string", this.getPackageName()); fieldName.setText(this.getString(stringId)); fieldName.setTextSize(16); fieldName.setPadding(fieldName.getPaddingLeft(), fieldName.getPaddingTop(), fieldName.getPaddingRight() + 10, fieldName.getPaddingBottom()); fieldName.setOnClickListener(spinnerOpener); row.addView(fieldName); final TextView fieldValueLocal = new TextView(this); fieldValueLocal.setText(fieldLocal); fieldValueLocal.setTextSize(16); row.addView(fieldValueLocal); fieldValueLocal.setOnClickListener(spinnerOpener); fieldTable.addView(row); row = new TableRow(this); row.addView(new TextView(this));// add dummy control final TextView fieldValueRemote = new TextView(this); fieldValueRemote.setText(fieldRemote); fieldValueRemote.setTextSize(16); fieldValueRemote.setOnClickListener(spinnerOpener); row.addView(fieldValueRemote); sourceSelect.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position == 0) { fieldValueLocal.setTextAppearance(SweetConflictResolveActivity.this, R.style.textSelected); fieldValueRemote.setTextAppearance(SweetConflictResolveActivity.this, R.style.textUnselected); resolvedContacts[mPosResolved].set(nameOfField, fieldLocal); } else { fieldValueLocal.setTextAppearance(SweetConflictResolveActivity.this, R.style.textUnselected); fieldValueRemote.setTextAppearance(SweetConflictResolveActivity.this, R.style.textSelected); resolvedContacts[mPosResolved].set(nameOfField, fieldRemote); } } @Override public void onNothingSelected(AdapterView<?> view) { } }); row.setPadding(row.getLeft(), row.getTop() + 5, row.getRight(), row.getBottom() + 10); // Restore appropiate selections according to resolved contact if (resolvedContacts[mPosResolved].get(nameOfField).equals(fieldLocal)) { sourceSelect.setSelection(0); } else { sourceSelect.setSelection(1); } fieldTable.addView(row); }
From source file:com.kiwiteam.nomiddleman.TourPageActivity.java
/** * Adapter to select day, time and quantity of a tour * @param parent//w w w. j a v a2s . c om * @param view * @param position * @param id */ @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { int vId = parent.getId(); switch (vId) { /* * If day is selected, search for times at current day. */ case R.id.day: String day = parent.getItemAtPosition(position).toString(); ArrayList<String> times = tour.getTourSessionsTime(day); tTime = (Spinner) findViewById(R.id.time); tAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, times); tAdapter.notifyDataSetChanged(); tTime.setOnItemSelectedListener(this); tAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); tTime.setAdapter(tAdapter); break; /* * If time is selected, search for quantities on current day and time. */ case R.id.time: String time = parent.getItemAtPosition(position).toString(); ArrayList<Integer> quantities = tour.getTourSessionAvailability(tDay.getSelectedItem().toString(), time); tQty = (Spinner) findViewById(R.id.quantity); qAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, quantities); qAdapter.notifyDataSetChanged(); qAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); tQty.setAdapter(qAdapter); break; } }
From source file:app.sunstreak.yourpisd.MainActivity.java
private void setUpNavigationDrawer() { // navigation drawer mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); // Set the adapter for the list view mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list, mList)); class DrawerItemClickListener implements ListView.OnItemClickListener { @Override// w w w.ja v a 2s . c om public void onItemClick(AdapterView parent, View view, int position, long id) { mViewPager.setCurrentItem(position); mDrawerLayout.closeDrawers(); } } mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ toolbar, /* nav drawer icon to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description */ R.string.drawer_close /* "close drawer" description */ ); mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // getActionBar().setDisplayHomeAsUpEnabled(true); // getActionBar().setHomeButtonEnabled(true); }