Я пытаюсь установить шрифт для пользовательского шрифта. шрифт находится в подпапке папки с ресурсами, называемой "шрифты". Это код в моей функции onCreate(). Eclipse suddendly вызывает отладчик, говорящий "источник не найден",
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 в моей главной в данный момент
<?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>
Я не вижу ничего плохого в этом. Почему это воспитывает отладчик и ошибка "источник не найден"?
Вы видели, как отладчик eclipse ищет источник исключения. в следующий раз нажмите продолжить и посмотреть объявление журнала исключения в окне Logcat.
Вы должны вызвать setContentView(R.layout.main);
перед TextView tv = (TextView) findViewById(R.id.TitleAct_title);
, и, возможно, сбросить вызов setContentView(tv);
,