2015-04-23 27 views
-1

我已經使用解析數據庫創建了一個演示應用程序。在這個應用程序,我成功取回由解析輸入電話的靜態值的特定行數據到Android類似的代碼爲:如何檢索行數據通過在parse.com中使用移動號碼?

public void onClick(View arg0){ 
 
ParseQuery<ParseObject> query = ParseQuery.getQuery("_User"); 
 
query.whereEqualTo("phone", "456767"); 
 
query.findInBackground(new FindCallback<ParseObject>() { 
 
\t public void done(List<ParseObject> objects, ParseException e) { 
 
\t \t if (e == null) { 
 

 
\t \t \t String username = objects.get(0).getString(
 
\t \t \t \t \t "username"); 
 
\t \t \t String passcode = objects.get(0).getString(
 
\t \t \t \t \t "passcode"); 
 
\t \t \t String latitude = objects.get(0).getString(
 
\t \t \t \t \t "latitude"); 
 
\t \t \t String longitude = objects.get(0).getString(
 
\t \t \t \t \t "longitude"); 
 

 
\t \t \t // Locate the TextView 
 
\t \t \t txtusername = (TextView) findViewById(R.id.username); 
 
\t \t \t txtpasscode = (TextView) findViewById(R.id.passcode); 
 
\t \t \t txtlatitude = (TextView) findViewById(R.id.latitude); 
 
\t \t \t txtlongitude = (TextView) findViewById(R.id.longitude); 
 

 
\t \t \t txtusername.setText(username); 
 
\t \t \t txtpasscode.setText(passcode); 
 
\t \t \t txtlatitude.setText(latitude); 
 
\t \t \t txtlongitude.setText(longitude); 
 
\t \t \t Log.d("phone", "Retrieved " + objects.size()+ " phone");

現在我有點困惑,即如何當我在應用程序UI中的編輯文本字段中輸入電話號碼(存儲在解析數據庫中)時檢索相同的數據。

請解釋任何幫助,從你身邊表示讚賞。 database.but

+0

所以你想要得到來自EditTex的數字噸,然後用這個數字來查詢? –

回答

0

維韋克,

嘗試更換下面的查詢(取代當前的wherequalto的:

query.whereEqualTo("phone", yourEditText.getText().toString()); 

此外,您使用objects.get(0).... 。你是想爲所有的對象或只是'0'位置的對象做這件事嗎?如果你需要它的所有對象,你需要運行一個for循環:

for (int i = 0; i < winningNumbers.size(); i++) { 
    String username = objects.get(0).getString("username"); 
    String passcode = objects.get(0).getString("passcode"); 
} 
+0

感謝詹姆斯瓊斯 –

相關問題