本人小白啊,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那报错
解决方案 »
- Fail to connect to camera service
- 【问】关于android应用程序名字的问题
- andriod如何学习
- Android的broadcastReceiver在2.2和3.0中的不同表现
- android下的视频转码问题
- android4.4怎么去掉长按Home键呼出google search
- listview中的每个item定义的是一个tablelayout 然后呢tablelayout背景是张图片 问 我要怎么才能实现点击item变色
- avd启动两个程序.一个是SocketServer,一个是client(Socket).两个avd.ip都是10.0.2.15.怎样改其中一个IP?
- MTK 6753 camera 预览帧率不够
- 关于android studio的求助
- 如何根据不同的网络选择不同的字符串
- 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" />