package com.AndroidFeatureIcon;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
public class AndroidFeatureIconActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_LEFT_ICON);
setContentView(R.layout.main);
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,R.drawable.icon);
}
}
Note:
ReplyDeletegetWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,R.drawable.icon);
can be simplified to:
setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,R.drawable.icon);
in the same way that:
getWindow().requestWindowFeature(Window.FEATURE_LEFT_ICON);
can be simplified to:
requestWindowFeature(Window.FEATURE_LEFT_ICON);
but requestWindowFeature(Window.FEATURE_LEFT_ICON); show error and windows are force close
DeleteOh, and you probably are aware of this, but JIC, there's also Window.FEATURE_RIGHT_ICON, which then allows an icon on the left, or the right *or* both sides of the title bar.
ReplyDeleteNice series of singular-subject, targeted posts by the way :)