我是 android 新手..我创建了一个项目,在该项目中我创建了一个 studreg.class 和 studreg.xml 文件。还创建了一个 string.xml,因为我曾经想创建微调器..
现在 setContentView 无法识别 studreg.xml,而且我在 gen 文件夹中看不到任何 R.java。请参阅下面的 cod 并帮助我。
studreg.xml**
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">IITKOL</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="qualification">Select Highest Qualification</string>
<string-array name="list_qualification">
<item>item1</item>
<item>item2</item>
<item>item3</item>
<item>item4</item>
<item>item5</item>
<item>item6</item>
<item>item7</item>
<item>item8</item>
</string-array>
</resources>
studreg.java**
package iitkol.com;
import android.app.Activity;
import android.R;
import android.content.ContentValues;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
public class studreg extends Activity{
protected static final int LENGTH_LONG = 0;
private TextView st_heading;
private EditText st_name,st_phno,st_email;
private Spinner st_course,st_qlf;
private Button st_submit,st_reset;
private DataHelper dataHelper;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.studreg);
st_heading=(TextView)findViewById(R.id.heading);
st_name=(EditText)findViewById(R.id.edit_name);
st_phno=(EditText)findViewById(R.id.edit_contact);
st_email=(EditText)findViewById(R.id.edit_emailid);
st_course=(Spinner)findViewById(R.id.course);
st_qlf=(Spinner)findViewById(R.id.qlf);
st_submit=(Button)findViewById(R.id.btn_submit);
st_reset=(Button)findViewById(R.id.btn_reset);
st_submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ContentValues contentValues = new ContentValues();
contentValues.put("studname",st_name.getText().toString().trim());
contentValues.put("studphno",st_phno.getText().toString().trim());
contentValues.put("studemail",st_email.getText().toString().trim());
contentValues.put("studqlf",st_qlf.getContext().toString().trim());
contentValues.put("studcourse",st_course.getContext().toString().trim());
dataHelper.insert("studform",contentValues);
Toast.makeText(studreg.this,"Thanks for registering.We will contact you shortly",LENGTH_LONG).show();
}
});
}
strings.xml**
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">IITKOL</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="qualification">Select Highest Qualification</string>
<string-array name="list_qualification">
<item>item1</item>
<item>item2</item>
<item>item3</item>
<item>item4</item>
<item>item5</item>
<item>item6</item>
<item>item7</item>
<item>item8</item>
</string-array>
</resources>