我的应用程序正在显示解析数据库中的数据,但我必须通过查询来区分在一个列表视图中它显示donars的名称,并在下一个列表中显示接受者的名称。
接受者列表代码
public class Donar_Acceptor_list extends Activity {
// Declare Variables
ListView listview;
List<ParseObject> ob;
ProgressDialog mProgressDialog;
// ParseQueryAdapter适配器;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.donar_acceptor_list);
final ParseQueryAdapter adapter = new ParseQueryAdapter(this, "Data");
adapter.setTextKey("username");
ListView listView = (ListView) findViewById(R.id.list);
listView.setAdapter(adapter);
ParseQueryAdapter.QueryFactory<ParseObject> factory =
new ParseQueryAdapter.QueryFactory<ParseObject>() {
public ParseQuery create() {
ParseQuery query = new ParseQuery("Data");
query.whereEqualTo("DonAcc", "donar");
// query.orderByDescending("moneySpent");
return query;
}
};
ParseQueryAdapter<ParseObject> Adapter = new ParseQueryAdapter<ParseObject> (this, factory);
adapter.setTextKey("username");
// Attach it to your ListView, as in the example above
ListView listVieww = (ListView) findViewById(R.id.list);
listVieww.setAdapter(adapter);
}
}
这是针对donars list
public class donar_list extends Activity {
// Declare Variables
ListView listview;
List<ParseObject> ob;
ProgressDialog mProgressDialog;
// ParseQueryAdapter适配器;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.donar_list);
final ParseQueryAdapter adapter = new ParseQueryAdapter(this, "Data");
adapter.setTextKey("username");
ListView listView = (ListView) findViewById(R.id.list);
listView.setAdapter(adapter);
ParseQueryAdapter.QueryFactory<ParseObject> factory =
new ParseQueryAdapter.QueryFactory<ParseObject>() {
public ParseQuery create() {
ParseQuery query = new ParseQuery("Data");
query.whereEqualTo("DonAcc", "acceptor");
// query.orderByDescending("moneySpent");
return query;
}
};
ParseQueryAdapter<ParseObject> Adapter = new ParseQueryAdapter<ParseObject>(this, factory);
adapter.setTextKey("username");
// Attach it to your ListView, as in the example above
ListView listVieww = (ListView) findViewById(R.id.list);
listVieww.setAdapter(adapter);
}
}