我已经搜索过这个,但我没有为我工作。我尝试了很多。我已经清理了项目,添加了 com.package.name.R。清洁后我仍然收到错误消息。我真的需要帮助,因为我是 Android 开发的新手。请让我理解。谢谢,这里是代码:
package com.gunnarco.gunnarscalculator;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.gunnarco.gunnarscalculator.R;
public class CalculatorActivity extends Activity {
public String str ="";
Character op = 'q';
int i,num,numtemp;
EditText showResult;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
showResult = (EditText)findViewById(R.id.result_id);
这是xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="@+id/result_id"
android:layout_width="fill_parent"
android:layout_height="120dp"
/>