error: incompatible types: int cannot be converted to Toolbar R.drawable.ic_drawer & cannot find symbol "mDrawerToggle = new ActionBarDrawerToggle("
error: incompatible types: int cannot be converted to Toolbar R.drawable.ic_drawer & cannot find symbol "mDrawerToggle = new ActionBarDrawerToggle("
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.multidex.MultiDex;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.drawerlayout.widget.DrawerLayout;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
并出现此错误“错误:类型不兼容:无法将 int 转换为工具栏 R.drawable.ic_drawer 并且无法找到符号“mDrawerToggle = new ActionBarDrawerToggle("
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
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 */
) {
您正在使用这个 constructor:
ActionBarDrawerToggle(Activity activity,
DrawerLayout drawerLayout,
Toolbar toolbar,
int openDrawerContentDescRes,
int closeDrawerContentDescRes)
问题在于
R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */
你必须通过Toolbar
。
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.multidex.MultiDex;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.drawerlayout.widget.DrawerLayout;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
并出现此错误“错误:类型不兼容:无法将 int 转换为工具栏 R.drawable.ic_drawer 并且无法找到符号“mDrawerToggle = new ActionBarDrawerToggle("
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
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 */
) {
您正在使用这个 constructor:
ActionBarDrawerToggle(Activity activity,
DrawerLayout drawerLayout,
Toolbar toolbar,
int openDrawerContentDescRes,
int closeDrawerContentDescRes)
问题在于
R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */
你必须通过Toolbar
。