package com.sinch.messagingtutorial.app;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseQuery;
import com.parse.ParseUser;

import java.util.ArrayList;
import java.util.List;

public class ListUsersActivity extends Activity {

    private String currentUserId;
    private ArrayAdapter<String> namesArrayAdapter;
    private ArrayList<String> names;
    private ListView usersListView;

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

        setConversationsList();
    }

    private void setConversationsList() {
        currentUserId = ParseUser.getCurrentUser().getObjectId();
        names = new ArrayList<String>();

        ParseQuery<ParseUser> query = ParseUser.getQuery();
        query.whereNotEqualTo("objectId", currentUserId);
        query.findInBackground(new FindCallback<ParseUser>() {
            public void done(List<ParseUser> userList, ParseException e) {
                if (e == null) {
                    for (int i=0; i<userList.size(); i++) {
                        names.add(userList.get(i).getUsername().toString());
                    }

                    usersListView = (ListView)findViewById(R.id.usersListView);
                    namesArrayAdapter =
                        new ArrayAdapter<String>(getApplicationContext(),
                            R.layout.user_list_item, names);
                    usersListView.setAdapter(namesArrayAdapter);
                } else {
                    Toast.makeText(getApplicationContext(),
                        "Error loading user list",
                            Toast.LENGTH_LONG).show();
                }
            }
        });
    }
}

@@ -115,16 +115,77 @@
 il.Log;%0A
+import android.view.View;%0Aimport android.widget.AdapterView;%0A
 import a
@@ -1787,16 +1787,549 @@
 apter);%0A
+%0A                    usersListView.setOnItemClickListener(new AdapterView.OnItemClickListener() %7B%0A                        @Override%0A                        public void onItemClick(AdapterView%3C?%3E a, View v, int i, long l) %7B%0A                            Toast.makeText(getApplicationContext(),%0A                                %22You clicked on user: %22 + i,%0A                                    Toast.LENGTH_SHORT).show();%0A                            //Look up user id & open conversation%0A                        %7D%0A                    %7D);%0A%0A
         

Make user list clickable