Bartos Bartos - 3 months ago 8
Android Question

Getting null at setting actionBar icon

I've got problem with my actionBar. Tryin' to set an icon but still getting null :/ Here's code :

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getActionBar().setIcon(R.drawable.logo);
getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#51717e")));

}


Ofc I've got logo in my drawable folder. Both lines are incorrect - Icon and Background color. Help :/

Answer

Try to set the background and icon in your styles.xml

Comments