本人小白啊,C++转来的,什么都不懂,求通俗易懂答案
搭好了android开发平台,想运行下hello world ,从网上抄了点代码,结果有错误package android.hello;import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;public class HelloWorldActivity extends Activity {
private TextView txtView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.txtView = (TextView) findViewById(R.id.txtView);
if(this.txtView!=null){
this.txtView.setText("Hello World");
}
}
}this.txtView = (TextView) findViewById(R.id.txtView);这句的id那报错
搭好了android开发平台,想运行下hello world ,从网上抄了点代码,结果有错误package android.hello;import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;public class HelloWorldActivity extends Activity {
private TextView txtView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.txtView = (TextView) findViewById(R.id.txtView);
if(this.txtView!=null){
this.txtView.setText("Hello World");
}
}
}this.txtView = (TextView) findViewById(R.id.txtView);这句的id那报错
解决方案 »
- listview滑动的时候报错java.lang.IllegalArgumentException
- imageView里面有什么属性可以使得图片随着分辨率而变,请各位仁兄说下,网上找了好多没找到。
- android中如何实现搜索框布局
- android的环境配置
- 关于URLConnection.setUseCaches(true);
- 关于在程序内切换语言的问题
- 如何在UI线程中暂停子线程啊
- 关于保险术语的学习
- 请教SimpleAdapter适配问题
- Android应用更新远程加载xml文件的问题,希望知道的朋友帮忙解答!不胜感激!
- 如何根据不同的网络选择不同的字符串
- id cannot be resolved or is not a field
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" > <TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" /></LinearLayout>
把TextView加一个id: <TextView
android:id="@+id/txtView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />