0
該應用程序非常簡單(並在IOS上完成),但在Android版本中,我不確定如何檢索編寫「Post」但顯示它的ParseUser。如何顯示寫入帖子的ParseUser?
謝謝你,原諒我的無知,但我正在努力學習。
另外我如何排序我的查詢,使最新的帖子是頂部?
public class ParseListActivity extends ListActivity {
List<Posts> posts = new ArrayList<Posts>();
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.parse_list);
ParseQuery<Posts> query = new ParseQuery<Posts>("Posts");
query.findInBackground(new FindCallback<Posts>() {
@Override
public void done(List<Posts> list, ParseException e) {
if (e != null){
Toast.makeText(ParseListActivity.this, "Error " + e, Toast.LENGTH_SHORT).show();
}
for (Posts post : list){
Posts newPost = new Posts();
//newPost.setDate(post.getDate());
newPost.setContent(post.getContent());
posts.add(newPost);
}
ArrayAdapter<Posts> adapter = new ArrayAdapter<Posts>(ParseListActivity.this, android.R.layout.simple_list_item_1, posts);
setListAdapter(adapter);
}
});
}
}
Post.java:
@ParseClassName("Posts")
public class Posts extends ParseObject {
public String getContent(){
return getString("content");
}
public void setContent(String content){
put("content", content);
}
@Override
public String toString(){
return getString("date") + "\n" + getString("content");
}
}