我有简单的代码
package com.zim32;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class TestActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView textvew = (TextView)findViewById(R.id.logtext);
}
}
textView为null。为什么? 这是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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:id="@+id/logtext"
/>
</LinearLayout>
我找到了关于onFinishInflate的一些事情。我应该在哪里使用它?