我从mysql数据库获取数据并将textView用于确保我得到它们。问题是我无法想办法实际使用它们。例如,我想检查用户插入的代码是否等于我从db获得的代码。这是守则的JSON部分。
private void showJSON(String response){
String Code="";
String Latitude="";
String Longitude="";
String Information= "";
String Question= "";
String Answer1= "";
String Answer2= "";
String Answer3= "";
String Answer4= "";
String RightAnswer= "";
String Trigger= "";
try {
JSONObject jsonObject = new JSONObject(response);
JSONArray result = jsonObject.getJSONArray(Config.JSON_ARRAY);
JSONObject tripData = result.getJSONObject(0);
Code = tripData.getString(Config.KEY_CODE);
Latitude = tripData.getString(Config.KEY_LATITUDE);
Longitude = tripData.getString(Config.KEY_LONGITUDE);
Information = tripData.getString(Config.KEY_INFORMATION);
Question = tripData.getString(Config.KEY_QUESTION);
Answer1 = tripData.getString(Config.KEY_ANSWER1);
Answer2 = tripData.getString(Config.KEY_ANSWER2);
Answer3 = tripData.getString(Config.KEY_ANSWER3);
Answer4 = tripData.getString(Config.KEY_ANSWER4);
RightAnswer = tripData.getString(Config.KEY_RIGHTANSWER);
Trigger = tripData.getString(Config.KEY_TRIGGER);
} catch (JSONException e) {
e.printStackTrace();
}
textViewResult.setText("Code:\t" + Code + "\nLatitude:\t" + Latitude + "\nLongitude:\t" + Longitude + "\nInformation:\t" + Information + "\nQuestion:\t" + Question + "\nAnswer1:\t" + Answer1 + "\nAnswer2:\t" + Answer2 + "\nAnswer3:\t" + Answer3 + "\nAnswer4:\t" + Answer4 + "\nRightAnswer:\t" + RightAnswer + "\nTrigger:\t" + Trigger);
}
答案 0 :(得分:0)
假设此用户输入了#34;代码"是edittext上的字符串。
edittext.getText()。toString()。equals("来自响应的代码")