我一直在試圖讓這段Android代碼工作一段時間,並且eclipse在不應該有這種情況時給我這樣有用的語法錯誤。我檢查了我的括號,我有正確的號碼,我相信他們都是他們應該在的地方。這是從教程複製和粘貼的代碼,稍作調整。所提供的代碼完整地工作,但我的版本給出了錯誤。我沒有改變那麼多。對沒有任何明顯錯誤的令牌的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);
我不知道什麼可能是錯的。代碼結構上沒有改變。第一個錯誤由靜態最終字符串KEY_SYNC_STATUS =「syncStatus」;是令牌「;」上的一個Synatx錯誤,{預期在此令牌之後
OnCreate方法上的兩個錯誤是令牌「(」expected; Syntax Error on token「)」上的語法錯誤;任何幫助表示讚賞
方括號在哪裏結束onCreate和Activity? – Razgriz
括號全部出現並且正確,我對它們進行了計數並進行了雙重檢查(這裏僅包含300行代碼以便於閱讀) –