Android ParseQueryAdapter显示空白列表

Android ParseQueryAdapter显示空白列表,android,android-listview,parse-platform,android-parsequeryadapter,Android,Android Listview,Parse Platform,Android Parsequeryadapter,所以我遵循了创建自定义ParseQueryAdapter的教程,但由于某些原因,我的listview没有被填充 列表视图活动 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_listusers); //Initialize the subclass of

所以我遵循了创建自定义ParseQueryAdapter的教程,但由于某些原因,我的listview没有被填充

列表视图活动

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_listusers);

    //Initialize the subclass of PQM
    listViewAdapter = new ListViewAdapter(this);

    //Initialize ListView and set view to listadapter
    usersListView = (ListView) findViewById(R.id.usersListView);
    usersListView.setAdapter(listViewAdapter);
ListViewAdapter

public class ListViewAdapter extends ParseQueryAdapter<ParseObject> {

public ListViewAdapter(Context context){
    //Use Query factory to constuct a PQA that will not include the current user
    super(context, new ParseQueryAdapter.QueryFactory<ParseObject>(){
       public ParseQuery create(){
           String currentUserId = ParseUser.getCurrentUser().getObjectId();
           ParseQuery query = new ParseQuery("User");
           query.whereNotEqualTo("objectId", currentUserId);
           return query;

       }
    });
}

//Customise the layout by overriding getItemView
@Override
public View getItemView(ParseObject object, View v, ViewGroup parent){
    if (v == null){
        v = View.inflate(getContext(), R.layout.user_list_items, null);
    }

    super.getItemView(object, v, parent);

    //Add the username textview
    TextView userListItem = (TextView) v.findViewById(R.id.text1);
    userListItem.setText(object.getString("username"));

    //Add the status textview
    TextView userListSubItem = (TextView) v.findViewById(R.id.userListSubItem);
    userListSubItem.setText(object.get("status").toString());
    return v;
}

}
活动列表用户XML文件

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/logout"
        android:id="@+id/logoutButton"
        android:gravity="center_vertical|center_horizontal"
        android:layout_gravity="center_horizontal"
        android:background="@color/dark_gray"
        android:textSize="24sp"
        android:padding="15dp"
        android:textColor="@color/heartbeat_red" />

    <ListView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="16dp"
        tools:context="com.sinch.messagingtutorialskeleton.ListUsersActivity"
        android:background="#ffffff"
        android:id="@+id/usersListView"
        >
    </ListView>

</LinearLayout>
    <?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TextView
        android:id="@+id/text1"
        android:textColor="#a9a9a9"
        android:padding="16dp"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:textSize="20sp">
    </TextView>

    <TextView
        android:id="@+id/userListSubItem"
        android:textColor="#a9a9a9"
        android:padding="16dp"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/text1"
        android:textSize="16sp">
    </TextView>

</LinearLayout>
用户列表项XML文件

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/logout"
        android:id="@+id/logoutButton"
        android:gravity="center_vertical|center_horizontal"
        android:layout_gravity="center_horizontal"
        android:background="@color/dark_gray"
        android:textSize="24sp"
        android:padding="15dp"
        android:textColor="@color/heartbeat_red" />

    <ListView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="16dp"
        tools:context="com.sinch.messagingtutorialskeleton.ListUsersActivity"
        android:background="#ffffff"
        android:id="@+id/usersListView"
        >
    </ListView>

</LinearLayout>
    <?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TextView
        android:id="@+id/text1"
        android:textColor="#a9a9a9"
        android:padding="16dp"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:textSize="20sp">
    </TextView>

    <TextView
        android:id="@+id/userListSubItem"
        android:textColor="#a9a9a9"
        android:padding="16dp"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/text1"
        android:textSize="16sp">
    </TextView>

</LinearLayout>
我对Android比较陌生,对解析也很陌生,我看不出哪里出了问题,解析工作很好,因为我之前有一个使用解析登录的活动

非常感谢,


编辑:所以我刚刚在Parse.com中创建了一个新类,并查询了该类,而不是用户和工作的类,不确定您是否不能在用户类上使用ParseQueryAdapter,或者我试图查询它的方式是否错误?

感谢@cYrixmorten,在构造正常的解析查询时,您必须将用户类称为_user

行从

ParseQuery query = new ParseQuery("User");


在我看来是正确的。没有logcat消息/错误?也许ParseQueryUser应该是ParseQuery_User@cYrixmorten是的,就是这样!我没有意识到在使用ParseObject时必须将User类称为_User,我以前只使用过ParseUser,但不确定它是否能与使用ParseObject的ParseQueryAdapter的所有教程一起使用。谢谢,很高兴成功了:没问题