为什么我不能在最后一行使用setContentView(R.layout.main)
而没有setContentView(tv)
?请向我解释这一点。关于android应用程序“HelloWorld”
package com.mue.helloworld;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloWorldActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android i am suvankar");
setContentView(tv);
}
}
没有得到?您可以在此代码的最后一个函数中设置setContentView(R.layout.main).............是什么问题? –