【发布时间】:2016-03-07 20:57:00
【问题描述】:
我有这些代码:
btnStart = (Button) findViewById(R.id.buttonstart);
btnStop = (Button) findViewById(R.id.buttonstop);
ipfield = (EditText) findViewById(R.id.ipfield);
portfield = (EditText) findViewById(R.id.portfield);
和
addPreferencesFromResource(R.xml.preferences);
它给了我这些错误:
buttonstart 无法解析或不是字段
buttonstop 无法解析或不是字段
ipfield 无法解析或不是字段
portfield 无法解析或不是字段
xml无法解析或不是字段
所以我进入 R 看看能否找到它们,但它们不存在。我尝试手动设置它们,但仍然出现错误。我多次清理项目,R 仍然没有生成它们。
这些是我的导入:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
Button btnStart, btnStop;
EditText ipfield, portfield;
【问题讨论】:
-
你为什么要做
addPreferencesFromResource(R.xml.preferences);这是一个设置活动? -
您做错了事并提出问题以不包括 R.Java 文件中的某些字段。请正确提问。
-
您的 xml 文件可能有错误。这就是 R 文件没有生成的原因。我的个人建议 - 请跳进 Android 工作室。参考这个 - stackoverflow.com/a/30284292/3879847
标签: android