给activity标题栏添加图标

设置在左边的图标

   getWindow().requestFeature(Window.FEATURE_LEFT_ICON);
        setContentView(R.layout.main);
        getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.pic1);

设置在右边的图标

   getWindow().requestFeature(Window.FEATURE_RIGHT_ICON);
        setContentView(R.layout.main);
        getWindow().setFeatureDrawableResource(Window.FEATURE_RIGHT_ICON, R.drawable.pic1);

 

注意:getWindow().requestFeature(Window.FEATURE_LEFT_ICON);必须要在setContentView前面使用

     

posted @ 2012-07-16 16:03  那些人追过的年  阅读(2030)  评论(0编辑  收藏  举报