0

for (int i = 1; i <= totalfriends; i++) {

// Cast the integer into a string.
Integer j = new Integer(i);
// We need to retrieve the JSONObject but it's first
// stored in an array.
JSONArray friendarray = obj.getJSONArray(j.toString());
JSONObject friendobject = friendarray.getJSONObject(0);
fname = friendobject.getString("firstname");
lname = friendobject.getString("lastname");
uid = friendobject.getString("uid");
contactNameList.add(fname + " " + lname);
contactIdList.add(uid);
// add to arraylist
//Store the above in a data structure}

contactMenu = contactNameList.toArray(new String[contactNameList.size()]); idMenu = contactIdList.toArray(new String[contactIdList.size()]); contactAdapter = 新的 ArrayAdapter

// After store everything into datastructure, put the code
                // inside run() and loop again and display the friendlist.
                runOnUiThread(new Runnable() {
                    public void run() {
                        setListAdapter(contactAdapter);
                        // Here, loop through the data structure and setup
                        // the friend list.

                    }
                });
4

1 回答 1

0

您可以:

  1. 制作一个垂直的 LinearLayout,将您的搜索栏作为第一个孩子,并将 ListView 作为第二个孩子。
  2. 在设置它的适配器之前,在 ListView 上调用 ListView.addHeaderView()。在这种情况下,您的搜索视图(可能是 Edittext)将与列表中的其余项目一起滚动
  3. 如果您有一个 ActionBar,请在操作栏中放置一个项目以允许搜索。
于 2013-08-03T23:59:54.893 回答