androidandroid-listviewparse-platformandroid-parsequeryadapter

Parse Android Studio ListView


Well guys, i'm just trying to creat a listView of Objects from a Parse query. So i don't know too much about list views in android but someone can tell me how to implement that? Or do you have an tutorial that can explain what should I do?

Thank you very much!


Solution

  • ListView is a view group that displays a list of scrollable items. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database query and converts each item result into a view that's placed into the list.

    so create your listview inside xml file using ListView element for example

    <ListView
      android:id="@android:id/list"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" >
    </ListView> 
    

    Then in your main activity. Make the use of Adapter to fill your list

    final ListView listview = (ListView) findViewById(R.id.list);
        String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
            "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
            "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux",
            "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2",
            "Android", "iPhone", "WindowsMobile" };
    
        final ArrayList<String> list = new ArrayList<String>();
        for (int i = 0; i < values.length; ++i) {
          list.add(values[i]);
        }
        final StableArrayAdapter adapter = new StableArrayAdapter(this,
            android.R.layout.simple_list_item_1, list);
        listview.setAdapter(adapter);
    

    This will populate all the items from values array into list

    for more example and tutorial http://developer.android.com/guide/topics/ui/layout/listview.html