0
以下是我嘗試基於3個參數進行查詢的代碼。但是下面的查詢適用於OR邏輯函數。有沒有人有任何線索如何與邏輯功能。我試圖按照文檔中的說明正常列出它們,但它總是返回一個空列表。如何在parsequery中執行AND
public class ResterauntList1 extends Activity {
String rValue, cValue, lValue;
ArrayAdapter<String> adapter;
ProgressDialog mProgressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_resteraunt_list1);
rValue = getIntent().getStringExtra("restrauntName");
cValue = getIntent().getStringExtra("restrauntCuisine");
lValue = getIntent().getStringExtra("restrauntLocation");
populateList(rValue, cValue, lValue);
}
private void populateList(final String rValue, final String cValue,
final String lValue) {
ParseQueryAdapter.QueryFactory<ParseObject> factory = new ParseQueryAdapter.QueryFactory<ParseObject>() {
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public ParseQuery create() {
ParseQuery<ParseObject> query = new ParseQuery("resdb");
query.whereEqualTo("name", rValue);
query.whereEqualTo("cuisine", cValue);
query.whereEqualTo("area", lValue);
return query;
}
};
ParseQueryAdapter<ParseObject> adapter = new ParseQueryAdapter<ParseObject>(
this, factory);
adapter.setTextKey("name");
adapter.addOnQueryLoadListener(new OnQueryLoadListener<ParseObject>() {
@Override
public void onLoading() {
mProgressDialog = new ProgressDialog(ResterauntList1.this);
mProgressDialog
.setTitle("Searching for Restaurants matching your search");
mProgressDialog.setMessage("Loading...");
mProgressDialog.setIndeterminate(false);
mProgressDialog.show();
}
@Override
public void onLoaded(List<ParseObject> objects, Exception e) {
mProgressDialog.dismiss();
}
});
final ListView listView = (ListView) findViewById(R.id.restListView1);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
ParseObject object = (ParseObject) listView
.getItemAtPosition(position);
String Id = object.getObjectId();
Intent i = new Intent(getApplicationContext(),
SingleRestraunt.class);
i.putExtra("restId", Id);
startActivity(i);
}
});
}
不返回任何錯誤,但它總是返回一個空的列表視圖。有什麼建議麼?就像額外的OR類型查詢一樣。
沒有人,我已經試過這個,這是它不工作的問題,它返回一個空列表。 – Androider 2014-09-03 18:28:48
然後你的數據是問題,因爲這是做AND查詢的正確方法。 – 2014-09-03 23:59:43
然後我必須同意@TimothyWalters。對不起,我不能提供更多幫助。 – 2014-09-04 05:48:35