2012-05-13 8 views
-1

위젯 개발로 인해 내 자신의 글꼴을 정의 할 때 requrement가 있습니다 (때때로 SharedProperties를 통해 변경할 수 있음). 내가 여기에 본 soultion FOandroid 위젯의 assets 디렉토리에있는 글꼴 변경

하나는 사용하는 것입니다

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

을하지만 문제는 다음의 onUpdate() 메소드는

findViewById를

익숙 dosn't 내 텍스트를 업데이트하기 위해 RemoteView를 사용하여 TextView로 접근하는 방법.

미리 감사드립니다.

답변

0

사용자 정의 TextView를 작성하여 TextView를 확장하고 초기화시 Typeface를 설정하십시오.

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. 
     } 

    } 
0

사용 context.getassets() ; 컨텍스트

Typeface font = Typeface.createFromAsset(context.getAssets(), "fonts/Century_Gothic.ttf"); 
의 onUpdate

에 전달
관련 문제