import android.app.DatePickerDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Configuration; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.DatePicker; import android.widget.ImageButton; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import android.widget.Toolbar; import java.util.Calendar; public class MainActivity extends AppCompatActivity { private TextView mDateDisplayStart; private TextView mDateDisplayEnd; private ImageButton mPickDateStart; private ImageButton mPickDateEnd; private String[] mScreenTitles; private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBarDrawerToggle mDrawerToggle; private CharSequence mDrawerTitle; private CharSequence mTitle; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mDateDisplayStart = (TextView) findViewById(R.id.dateStart); mDateDisplayEnd = (TextView) findViewById(R.id.dateEnd); mPickDateStart = (ImageButton) findViewById(R.id.showDateStartPicker); mPickDateEnd = (ImageButton) findViewById(R.id.showDateEndPicker); final Context context = this; mPickDateStart.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { MyDatePicker dlg = new MyDatePicker(context); dlg.setTextView(mDateDisplayStart); dlg.show(); } }); mPickDateEnd.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { MyDatePicker dlg = new MyDatePicker(context); dlg.setTextView(mDateDisplayEnd); dlg.show(); } }); mTitle = mDrawerTitle = getTitle(); mScreenTitles = getResources().getStringArray(R.array.screen_array); 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_item, mScreenTitles)); // Set the list's click listener mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); mDrawerToggle = new ActionBarDrawerToggle( this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description */ R.string.drawer_close /* "close drawer" description */ ) { 

Highlights the last five lines with this error. When compiling displays the following:

 Error:(81, 25) error: no suitable constructor found for ActionBarDrawerToggle(MainActivity,DrawerLayout,int,int,int) constructor ActionBarDrawerToggle.ActionBarDrawerToggle(Activity,DrawerLayout,Toolbar,int,int) is not applicable (argument mismatch; int cannot be converted to Toolbar) constructor ActionBarDrawerToggle.<T>ActionBarDrawerToggle(Activity,Toolbar,DrawerLayout,T,int,int) is not applicable (cannot infer type-variable(s) T (actual and formal argument lists differ in length)) where T is a type-variable: T extends Drawable,DrawerToggle declared in constructor <T>ActionBarDrawerToggle(Activity,Toolbar,DrawerLayout,T,int,int) 

    1 answer 1

    Try this

     mDrawerToggle = new ActionBarDrawerToggle( this, mDrawerLayout, android.R.string.ok, android.R.string.ok) { public void onDrawerClosed(View view) { supportInvalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { } }; 
    • This code is present, but the error is still highlighted ( - Cyril
    • ??? I gave a slightly different code, not the one you have in question. You have a mistake in that you are using the wrong ones, in the wrong order or the wrong number of arguments in the constructor ActionBarDrawerToggle - JuriySPb ♦
    • Thank you, figured out - Cyril