Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use following code for setting icon on title of my app activity but if i use following code my app crash.

C#
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_LEFT_ICON);
contentView(R.layout.youLayout);
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_alert);


I also try

In AndroidMainfest.xml

C#
<activity
android:name="xyz"
android:label="Label"
android:icon="@drawable/ic_icon">


but this code also not working

So please tell me How to set icon on activity title
Posted
Comments
Krunal Rohit 26-Oct-15 13:14pm    
getActionBar().setIcon(R.drawable.my_icon);

-KR

1 solution

Within AndroidManifest.xml its not activity but application

Java
<application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Holo.Light">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
           
        </activity>
    </application>



Give that a try

/Darren
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900