Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:无法更改窗口标题中的图像_Android_Android Imageview - Fatal编程技术网

Android:无法更改窗口标题中的图像

Android:无法更改窗口标题中的图像,android,android-imageview,Android,Android Imageview,我有一个父活动(所有其他活动都从中扩展)-窗口标题中有一个“导航抽屉切换”图标 每次单击抽屉图标(打开/关闭抽屉)时,我都要更改“导航抽屉切换”图像 问题是当调用openDrawer和closeDrawer时,“imgDrawer”并没有改变。 这是因为“imgDrawer”图标位于窗口标题中还是其他位置?可能setContentView和setFeatureInt布局相同,在设置标题布局之前调用getWindow().setFeatureInt。按如下方式操作: @Override

我有一个父活动(所有其他活动都从中扩展)-窗口标题中有一个“导航抽屉切换”图标

每次单击抽屉图标(打开/关闭抽屉)时,我都要更改“导航抽屉切换”图像

问题是当调用openDrawer和closeDrawer时,“imgDrawer”并没有改变。
这是因为“imgDrawer”图标位于窗口标题中还是其他位置?

可能
setContentView
setFeatureInt
布局相同,在设置标题布局之前调用
getWindow().setFeatureInt
。按如下方式操作:

 @Override
    protected void onCreate(Bundle savedInstanceState) {
    ....
    setContentView(R.layout.window_title);  

    ...
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
                R.layout.window_title);
    imgDrawer = (ImageView)getWindow().findViewById(R.id.imgdrawer);
}

或者传递包含具有不同is from的ImageView的布局。
setContentView
layout

在创建之前设置此布局。…getWindow().setFeatureInt(Window.FEATURE\u CUSTOM\u TITLE,R.layout.Window\u TITLE);
 @Override
    protected void onCreate(Bundle savedInstanceState) {
    ....
    setContentView(R.layout.window_title);  

    ...
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
                R.layout.window_title);
    imgDrawer = (ImageView)getWindow().findViewById(R.id.imgdrawer);
}