自定义ListView Android,ListView中没有显示任何结果

时间:2015-04-28 17:42:38

标签: android parse-platform

更新的代码;但是在运行应用程序时我仍然没有得到任何结果。

我正在使用ParseQueryAdapter;我正在查询用户,所以我正在使用ParseUser;似乎第一部分是对所有类型助产士用户的查询,然后获取我想要的特定类型的数据,将它们设置为TextViews

public class CustomMidwifeAdapter extends ParseQueryAdapter<ParseUser> {


    public CustomMidwifeAdapter(Context context) {
        // Use the QueryFactory to construct a PQA that will only show
        // Todos marked as high-pri
        super(context, new ParseQueryAdapter.QueryFactory<ParseUser>() {
            public ParseQuery create() {
                ParseQuery<ParseUser> query = new ParseQuery<ParseUser>("userType");
                query.whereEqualTo("userType", "midwife");
                query.findInBackground(new FindCallback<ParseUser>() {
                    @Override
                    public void done(List<ParseUser> parseUsers, ParseException e) {
                        if (e == null ) {

                            //query was successful


                        }

                    else {
                            //Something went wrong
                        }

                    }


                });



                return query;
            }
        });
    }



    public View getItemView(ParseUser object, View view, ViewGroup parent) {

        if (view == null) {
            view = View.inflate(getContext(), R.layout.activity_midwife_result_list, null);

        }

        super.getItemView(object, view, parent);


        // Add the practicename view
        TextView titleTextView = (TextView) view.findViewById(R.id.practicename);
        titleTextView.setText(object.getString("practicename"));

        // Add education view
        TextView EducationView = (TextView) view.findViewById(R.id.education);
        EducationView.setText(object.getString("education"));

        // Add yearsexperience view
        TextView ExperienceView = (TextView) view.findViewById(R.id.yearsinpractice);
        ExperienceView.setText(object.getString("yearsinpractice"));

        //Add practice philosophy view
        TextView PracticePhilosophyView = (TextView) view.findViewById(R.id.practicephilosophy);
        PracticePhilosophyView.setText(object.getString("practicephilosophy"));


        return view;
    }

}

这是活动

public class MidwifeResultList extends Activity {


    private ParseQueryAdapter<ParseObject> mainAdapter;

    private CustomMidwifeAdapter midwifeListAdapter;

    private ListView listView;

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

        //initialize main ParseQueryAdapter
        mainAdapter = new ParseQueryAdapter<ParseObject>(this, "userType");
        mainAdapter.setTextKey("practicename");
        mainAdapter.setTextKey("education");
        mainAdapter.setTextKey("yearsinpractice");
        mainAdapter.setTextKey("practicephilosophy");


        // Initialize the subclass of ParseQueryAdapter
        midwifeListAdapter = new CustomMidwifeAdapter(this);

        // Initialize ListView and set initial view to mainAdapter
        listView = (ListView) findViewById(R.id.lvMidwives);
        listView.setAdapter(mainAdapter);
        mainAdapter.loadObjects();

    }

我查看了我的列表视图,而且ID似乎是正确的。这基于此示例:https://parse.com/tutorials/parse-query-adapter

0 个答案:

没有答案