我想有在Android操作系统2.3.x版本使用Java安卓:自己的字体中的ListView
阅读下面的链接后一个ListView我自己的字体,却困:
http://developer.android.com/guide/topics/ui/themes.html http://stackoverflow.com/questions/4576441/custom-font-in-android-listview http://androidforums.com/android-lounge/143874-custom-typface-listview-row-layout.html
我不能在这里发布有用的东西。
我的主要问题是:
- 为什么我不能改变字体的列表视图,使用setTypeface?
- 为什么我不能在我的应用程序中为所有文本定义一个字体,而无需再次将其放入每个活动中?
- 是否有一个文档,它可以解决这个问题? Android SDK文档缺少大量的细节,例如otf Fonts正在使用的版本。
我知道我必须学习很多东西,并且我已经准备好了尽可能多的关于这个话题的书籍。但经过两天的猜测和尝试,我不得不寻求帮助。
Propably有人可以把我在正确的方向;)
为了给你一个小想法,我试图清理一些代码:
文件:RES /布局/ scores.xml(摘录自它)
<ListView
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00000000"
android:cacheColorHint="#00000000"
android:transcriptMode="disabled" >
</ListView>
文件:SRC/notneededasinfo/ScoresActivity.java(从它片断)
Resources myResources = getResources();
Typeface tf = Typeface.createFromAsset(myResources.getAssets(),"fonts/searstower.ttf");
TextView tv = (TextView) findViewById(android.R.id.list);
tv.setTypeface(tf);
Thx求助!
@你的代码显示一些错误?或者是什么问题? – 2012-03-02 10:28:55
问题是,我没有得到任何例外或错误,并且字体没有改变。 我认为,这只是我身边的一个小问题,就像一个错字。 – MrMarco 2012-03-02 10:31:29
只需将此myResources.getAssets()修改为getApplicationContext()。getAssets()并尝试。 – 2012-03-02 10:41:38