我想有在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