当前位置: 代码迷 >> Android >> 生手求教 android activity模板
  详细解决方案

生手求教 android activity模板

热度:50   发布时间:2016-04-28 05:20:09.0
新手求教 android activity模板
EntblogDetail.java代码:

package cn.myapp.activity;
import android.R;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;


public class EntblogDetail extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.blogdetail);//布局模板
showdata();
}
private void showdata()
{
String title=getIntent().getStringExtra("title");
TextView tv=(TextView)findViewById(R.id.textView1);
tv.setText("your choise is :"+title);
------------------------------------------------------------------------------
报错:
blogdetail cannot be resolved or is not a field


blogdetail 这个xml已经有了为什么不认呢

project下的clean,用过了还是不行

textView1 cannot be resolved or is not a field


------解决方案--------------------
import android.R;

应该是r文件导错了。
------解决方案--------------------
楼上正解,  你应该导入工程的 R 文件 

import cn.myapp.R 

你导入的是 import android.R; 导错了, 

删掉 import android.R; 重新导入一下
  相关解决方案