-1

ウィジェットの開発により、自分のフォントの定義に要件があります(SharedPropertiesを介して変更できる場合があります)。

私がここで見た魂の1つは、以下を使用することです。

TextView tv=(TextView)findViewById(R.id.yearthree_view);
Typeface font = Typeface.createFromAsset(this.getAssets(), "fonts/Century_Gothic.ttf"); 
tv.setTypeface(font);

しかし、問題は次のとおりです。onUpdate()メソッドに精通していない

findViewById

テキストを更新するためにRemoteViewsを使用してTextViewにアクセスする私のアプローチ。

前もって感謝します。

4

2 に答える 2

0

カスタムTextViewを作成してTextViewを拡張し、初期化時に書体を設定します。

public class CustomTextView extends TextView {

        public CustomTextView(Context context, AttributeSet attrs) {
            super(context, attrs);
            initTextFont(context);
        }

        public CustomTextView(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
            initTextFont(context);
        }

        private void initTextFont(Context context) {
            //Set font here.
        }

    }
于 2012-05-13T08:52:24.367 に答える
0

使用context.getassets() ; コンテキストは onUpdate で渡されます

Typeface font = Typeface.createFromAsset(context.getAssets(), "fonts/Century_Gothic.ttf"); 
于 2013-04-28T15:52:14.587 に答える