如何在活动标题上设置图标 [英] How to set icon on activity title
本文介绍了如何在活动标题上设置图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下代码在我的应用活动的标题上设置图标但是如果我使用以下代码我的应用程序崩溃。
I use following code for setting icon on title of my app activity but if i use following code my app crash.
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_LEFT_ICON);
contentView(R.layout.youLayout);
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_alert);
我也尝试
在AndroidMainfest.xml中
I also try
In AndroidMainfest.xml
<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
推荐答案
在AndroidManifest.xml中它不是活动而是应用程序
Within AndroidManifest.xml its not activity but application
<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>
试一试
/ Darren
Give that a try
/Darren
这篇关于如何在活动标题上设置图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文