我一直收到错误,说ActionBarDrawerToggle无法应用于v7.widget.Toolbar,因为我看了其他人如何解决类似的问题,他们现在都支持库文件,但错误不会因某种原因消失.
错误说ActionBarDrawerToggle中的ActionBarDrawerToggle()无法应用于android.support.v7.widget.Toolbar然后在实际参数R.id.drawable_ic_drawer(int)下
import android.support.v7.app.ActionBarDrawerToggle; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.content.SharedPreferences; import android.content.res.Configuration; import android.os.Bundle; import android.preference.PreferenceManager; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; import android.support.v7.widget.Toolbar;
mDrawerToggle = new android.support.v7.app.ActionBarDrawerToggle( getActivity(),/* host Activity */ mDrawerLayout,/* DrawerLayout object */ R.drawable.ic_drawer,/* nav drawer image to replace 'Up' caret */ R.string.navigation_drawer_open,/* "open drawer" description for accessibility */ R.string.navigation_drawer_close /* "close drawer" description for accessibility */ ) {