[英]ParseObject Subclass to simple ListView
I'm trying to create a simple list view from a list of ParseObjects
. 我正在尝试从
ParseObjects
列表创建一个简单的列表视图。 The issue is the toString
method doesn't seem to be overriding the super class, so I'm just getting the class name displayed (eg, com.parse.ParseObject@416161e8) in the list view. 问题是
toString
方法似乎没有覆盖超类,所以我只是在列表视图中显示类名(例如com.parse.ParseObject@416161e8) 。 I've created this exact setup before without using a ParseObject
and it works how I'd expect. 在不使用
ParseObject
情况下,我已经创建了此精确设置,并且它的工作方式与我期望的一样。 Am I just missing something simple? 我只是想念一些简单的东西吗?
My class that extends ParseObject
我的类扩展了
ParseObject
@ParseClassName("Foo")
public class Foo extends ParseObject {
public String getName(){
return getString("name");
}
public void setName(String name){
put("name", name);
}
public String getType(){
return getString("type");
}
public void setType(String type){
put("type", type);
}
@Override
public String toString() {
return getName();
}
}
My code that sets the listview adapter. 我的代码设置了列表视图适配器。
ParseQuery<Foo> query = ParseQuery.getQuery(Foo.class);
query.findInBackground(new FindCallback<Foo>() {
public void done(List<Foo> foos, ParseException e) {
if (e == null) {
listView.setAdapter(new ArrayAdapter<Foo>(context, android.R.layout.simple_list_item_1, foos));
} else {
}
}
});
Ugh, I missed in the docs about registering the sub class. gh,我错过了有关注册子类的文档。
Place ParseObject.registerSubclass(YOURSUBLCASS.class);
放置
ParseObject.registerSubclass(YOURSUBLCASS.class);
before Parse.initialize(...)
在
Parse.initialize(...)
之前
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.