Android的 - 构造函数ActionBarDrawerToggle未定义 [英] Android - The constructor ActionBarDrawerToggle is undefined
问题描述
我用这个code在我的OnCreate函数通过$ P $打开抽屉式导航pssing的应用程序图标。
I used this code in my oncreate function to open the navigation drawer by pressing the app icon.
ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(
this, /* host Activity */
(DrawerLayout) findViewById(R.id.left_drawer), /* DrawerLayout object */
getResources().getDrawable(R.drawable.ic_drawer), /* nav drawer icon to replace 'Up' caret */
getString(R.string.drawer_open), /* "open drawer" description */
getString(R.string.drawer_close) /* "close drawer" description */
) {
/** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
getActionBar().setTitle(R.string.title_activity_add);
}
/** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle(R.string.drawer_title);
}
};
现在它说:构造ActionBarDrawerToggle(AddActivity,DrawerLayout,绘制对象,字符串,字符串)是不确定的。我已经进口android.support.v4.app.ActionBarDrawerToggle。哪里的问题?
Now it says "The constructor ActionBarDrawerToggle(AddActivity, DrawerLayout, Drawable, String, String) is undefined". I have imported android.support.v4.app.ActionBarDrawerToggle. Where's the problem?
推荐答案
构造函数是不是 ActionBarDrawerToggle(AddActivity,DrawerLayout,绘制对象,字符串,字符串)
。这是 ActionBarDrawerToggle(活动,DrawerLayout,INT,INT,INT)
。改变你的最后三个参数是资源ID,引用资源ID的不是结果。
The constructor is not ActionBarDrawerToggle(AddActivity, DrawerLayout, Drawable, String, String)
. It is ActionBarDrawerToggle(Activity, DrawerLayout, int, int, int)
. Change your last three parameters to be the resource IDs, not the results of referencing the resource IDs.
这篇关于Android的 - 构造函数ActionBarDrawerToggle未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!