-1

I want to retrieve data from parse.com and show it in listview. but when i retrieve it and it shows me in hashcode. I have pasted picture of output.Please look into my query code and correct me. Here is code for pulling data from parse.com

ParseQuery<ParseUser> query = ParseUser.getQuery();
    query.findInBackground(new FindCallback<ParseUser>() {
        @Override
        public void done(List<ParseUser> list, ParseException e) {
            if (e != null) {
                Toast.makeText(getActivity(), "Error" + e, Toast.LENGTH_SHORT).show();
            } else {

                for (ParseUser user : list) {
                    ParseUser newUser = new ParseUser();

                    newUser.getString(user.getString("username"));
                    newUser.getString(user.getString("Latitude"));
                    newUser.getString(user.getString("Longitude"));
                    newUser.getString(user.getString("Bloodtype"));
                    newUser.getString(user.getString("Mobile"));
                    user1.add(newUser);

                }
                ArrayAdapter<ParseUser> adapter = new ArrayAdapter<>(getActivity(),android.R.layout.simple_list_item_1,user1);
                setListAdapter(adapter);

            }
        }
    });

enter image description here

Zeeshan Shabbir
  • 6,704
  • 4
  • 38
  • 74

1 Answers1

1

ArrayAdapter just use the toString of each object in the array. Every user that you add to list is displayed as a pointer, this is the to string method of the ParseUser object.

If you are trying to display all information about the user you should create a custom adapter and implement the getView method. If you want to check for now if it works correctly you can pass a list of just username for example and check if it works, then you can move on and implement your own adapter.

Edit: For creating custom adapter check this question

Community
  • 1
  • 1
galvan
  • 7,400
  • 7
  • 38
  • 55
  • How should i check it? any example code? and i have not idea how to make custom adapter – Zeeshan Shabbir Sep 07 '15 at 13:40
  • I edited my answer, check this link for creating a custom adapter with a custom layout, the adapter you are trying to use is to for displaying only one string in a row. – galvan Sep 07 '15 at 13:43
  • Ok if i use custom adapter then i don't need to use ListFragment? I am sorry for asking dumb questions. I am new into android – Zeeshan Shabbir Sep 07 '15 at 13:48
  • ListFragment is a fragment with embedded list. You still need to use ListFragment but instead of using ArrayAdapter in your code you should instantiate you own custom adapter. – galvan Sep 07 '15 at 13:50
  • Thanks. I will learn custom adapter now then i will implement it in my Fragment which extends ListAFragment – Zeeshan Shabbir Sep 07 '15 at 13:56
  • Thanks much. I followed as you told. It is working now – Zeeshan Shabbir Sep 08 '15 at 06:35