从 parse.com 检索数据并以 table 布局显示
Retrieving data from parse.com and displaying in a table layout
我能够根据日志检索数据,但不确定如何显示它们。我创建了一个带有 table 布局的 activity 和 table 带有文本视图的行来显示类别。
日志:
如我所见,此日志是 JSON。可能更好的方法是使用 Gson 反序列化。
如果只是想生成一个原型,可以使用ParseQueryAdapter。
代码来自 Parse.com 文档
// Inside an Activity
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Uses a layout with a ListView (id: "listview"), which uses our Adapter.
setContentView(R.layout.main);
ParseQueryAdapter<ParseObject> adapter = new ParseQueryAdapter<ParseObject>(this, "Instrument");
adapter.setTextKey("name");
adapter.setImageKey("photo");
ListView listView = (ListView) findViewById(R.id.listview);
listView.setAdapter;
}
https://parse.com/docs/android/guide#user-interface-parsequeryadapter
https://github.com/ParsePlatform/ParseUI-Android
您可以通过 queryFactory 自定义您的查询
https://parse.com/docs/android/guide#user-interface-customizing-the-query
或者您可以自定义 XXXAdapter(ListAdapter、ArrayAdapter、BaseAdapter)。
在调用 findInBG 之前显示加载动画。调用完成后,将此列表设置为您的适配器,然后 adapter.notifyDataSetChanged().
如果您只是不熟悉使用 ListView,您应该 Google 它。
我能够根据日志检索数据,但不确定如何显示它们。我创建了一个带有 table 布局的 activity 和 table 带有文本视图的行来显示类别。
日志:
如我所见,此日志是 JSON。可能更好的方法是使用 Gson 反序列化。
如果只是想生成一个原型,可以使用ParseQueryAdapter。
代码来自 Parse.com 文档
// Inside an Activity
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Uses a layout with a ListView (id: "listview"), which uses our Adapter.
setContentView(R.layout.main);
ParseQueryAdapter<ParseObject> adapter = new ParseQueryAdapter<ParseObject>(this, "Instrument");
adapter.setTextKey("name");
adapter.setImageKey("photo");
ListView listView = (ListView) findViewById(R.id.listview);
listView.setAdapter;
}
https://parse.com/docs/android/guide#user-interface-parsequeryadapter
https://github.com/ParsePlatform/ParseUI-Android
您可以通过 queryFactory 自定义您的查询
https://parse.com/docs/android/guide#user-interface-customizing-the-query
或者您可以自定义 XXXAdapter(ListAdapter、ArrayAdapter、BaseAdapter)。
在调用 findInBG 之前显示加载动画。调用完成后,将此列表设置为您的适配器,然后 adapter.notifyDataSetChanged().
如果您只是不熟悉使用 ListView,您应该 Google 它。