2011-08-26 6 views
1

글꼴을 사용자 지정 글꼴로 설정하려고합니다. 글꼴은 "글꼴"이라는 자산 폴더의 하위 폴더에 있습니다. 이것은 onCreate() 함수의 코드입니다. suddendly 말 디버거를 제공 이클립스Android에서 textView의 글꼴을 설정하려면 어떻게해야합니까?

Typeface centuryGothic = Typeface.createFromAsset(this.getAssets(), "fonts/Century_Gothic_Bold.ttf"); 
    TextView tv = (TextView) findViewById(R.id.TitleAct_title); 
    tv.setTypeface(centuryGothic); 
    setContentView(tv); 

이 순간

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 

<LinearLayout 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_weight="1"> 

    <TextView 
    android:text="@string/TitleAct_title" 
    android:id="@+id/TitleAct_title" 
    android:textColor="#fff" 
    android:gravity="center_horizontal" 
    android:background="#347" 
    android:textSize="15pt" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1"/> 

</LinearLayout>  
</LinearLayout> 

나는이 문제 아무것도 볼 수 없습니다에서 내 주요의 XML은 "소스를 찾을 수 없습니다." 왜 디버거를 가져오고 "소스를 찾을 수 없습니다"라는 오류가 발생합니까?

+0

"소스"는 무엇을 찾고 있습니까? 때로는 정확히 무엇을 찾고 있는지 알려주므로 적절하게 수정할 수 있습니다. 또한 "fonts/Century_Gothic_Bold.ttf"에 선도 "/"를 추가해 보았습니까? – Jack

답변

1

당신이 보았던 것은 이클립스 디버거가 예외의 원인을 찾는 것이었다. 다음 번에 continue를 누르고 logcat 창에서 예외 로그를 ​​확인하십시오.

TextView tv = (TextView) findViewById(R.id.TitleAct_title); 전에 setContentView(R.layout.main);으로 전화해야하며 setContentView(tv);으로 전화를 거는 것이 좋습니다.

+0

아 감사합니다! 이것은 안드로이드에서 코딩 한 첫 번째 시간이며, 먼저 넣어 줘야 할 필요가 있는지 몰랐습니다. 매우 감사 :-) – deztructicus

관련 문제