2012-06-25 4 views
2

나는 인터넷을 아무 쓸모없이 샅샅이 뒤졌습니다. 나는 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); 
} 

감사합니다!

+1

컴파일됩니까? 당신이''을 놓쳤다는 것을 알았지 만, 당신은 그것을 복사하지 않았 음을 확신한다. – Sam

+0

실수로'android.R'을 가져 왔습니까? – trichner

답변

2

프로그램을 청소 해 보셨습니까? 나는 이상한 일들이 일어나기 전에 저의 문제를 해결했습니다. 이 경우인지 확실하지 않습니다.

+0

나는 실제로 잘못된 자바 파일 o_O에있었습니다. 나는 Xcode 이후에 Eclipse의 팬이 아니다. 우는 소리. 나는 또한 코드를 조금 정리해야했지만, 알았다. 모두에게 감사드립니다. –

+0

lol, 저도 여기 저기에 타이머를 너무 많이했습니다. 나는 일식에 신경 쓰지 않는다. 그러나 내가 추측하는 약간의 지역에서 개선 할 여지를 볼 수 있었다. 전반적으로 나는 그것을 신경 쓰지 않지만. –

관련 문제