我一直试图让这段 Android 代码工作一段时间,当不应该出现语法错误时,eclipse 给了我非常有用的语法错误。我检查了我的括号,我得到了正确的数字,我相信它们都在它们应该在的地方。这是从教程中复制和粘贴的代码,并稍作调整。提供的代码全部有效,但我的版本给出了错误。我没有改变那么多。
public class MainActivity extends Activity{
Button Pull_Data;
// Define the TextViews
TextView client_Address1;
TextView client_Address2;
TextView client_Address3;
TextView client_Id;
// XML node keys
static final String KEY_ITEM = "Address"; // parent node
static final String KEY_PERSON = "addedByPerson";
static final String KEY_CITY = "addressCity";
static final String KEY_LINE_ONE = "addressLineOne";
static final String KEY_LINE_TWO = "addressLineTwo";
static final String KEY_STATE = "addressState";
static final String KEY_TYPE_ID = "addressTypeId";
static final String KEY_ZIP = "addressZip";
static final String KEY_CLIENT_ID = "clientId";
static final String KEY_COUNTRY_CODE = "countryCode";
static final String KEY_OBJECT_ID = "objectId";
static final String KEY_RECORD_ADDED_DATE = "recordAddedDate";
static final String KEY_RECORD_UPDATED_DATE = "recordUpdatedDate";
static final String KEY_RECORD_UPDATED_PERSON = "recordUpdatedPerson";
static final String KEY_SYNC_STATUS = "syncStatus"; //Syntax error is flagged here
// XML Data to Retrieve
Address = "";
addedByPerson = "";
addressCity = "";
addressLineOne = "";
addressLineTwo = "";
addressState = "";
addressTypeId = "";
addressZip = "";
clientId = "";
countryCode = "";
objectId = "";
recordAddedDate = "";
recordUpdatedDate = "";
recordUpdatedPerson = "";
syncStatus = "";
// Holds values pulled from the XML document using XmlPullParser
String[][] xmlPullParserArray = {{"Address", "0"},{"addedByPerson", "0"},{"addressCity", "0"},{"addressLineOne", "0"},{"addressLineTwo", "0"},
{"addressState", "0"},{"addressTypeId", "0"},{"addressZip", "0"},{"clientId", "0"},
{"countryCode", "0"},{"objectId", "0"},{"recordAddedDate", "0"},{"recordUpdatedDate", "0"},
{"recordUpdatedPerson", "0"},{"syncStatus", "0"}};
int parserArrayIncrement = 0;
// END OF NEW STUFF
@Override
protected void onCreate(Bundle savedInstanceState){ //Another error here, tagged at the first paren after onCreate
super.onCreate(savedInstanceState);
我不知道可能出了什么问题。从结构上讲,代码没有改变。第一个错误由 static final String KEY_SYNC_STATUS = "syncStatus"; 是令牌“;”上的 Synatx 错误,{ 预计在此令牌之后
OnCreate 方法的两个错误是 token "(" 预期的语法错误;和 token ")" 预期的语法错误;任何帮助表示赞赏