나는 인터넷을 아무 쓸모없이 샅샅이 뒤졌습니다. 나는 textview에 대한 글꼴을 설정하려고합니다. 그것은 내 main.xml 파일의 자체 LinearLayout에 있습니다. OnCreate에 코드를 작성할 때 ID 또는 부모 선형 레이아웃을 찾지 못합니다. 여기 코드는 다음과 같습니다findViewById - 중첩 LinearLayouts, 내 신분증을 찾지 못했습니다. - Android
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/background"
android:orientation="vertical"
android:weightSum="10.0" >
<LinearLayout
android:id="@+id/map_message_layout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1.0"
android:orientation="horizontal" >
<TextView
android:id="@+id/map_message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:text="@string/diagram" />
</LinearLayout>
그리고 다음에서 onCreate 방법 :
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LinearLayout = (LinearLayout) this.findViewById(R.id.map_message_layout)
TextView maptxt = (TextView) findViewById(R.id.map_message);
Typeface typeFace = Typeface.createFromAsset(getAssets(),"fonts/MuseoSans_100.otf");
maptxt.setTypeface(typeFace);
}
감사합니다!
컴파일됩니까? 당신이' LinearLayout>'을 놓쳤다는 것을 알았지 만, 당신은 그것을 복사하지 않았 음을 확신한다. – Sam
실수로'android.R'을 가져 왔습니까? – trichner