Android adding to an arraylist
<p>I have a chat program that displays I list of online users. The message back from the server is "RESP_USERLIST,,, etc.
Except I am having problems adding these usernames to my list.</p>

<p>Here is my current code:</p>

<pre><code>List &lt;String&gt; responseList = Arrays.asList(OnlineUsersPost.split(","));
    if (responseList.contains("RESP_USERLIST")){
        _onlineUsers = responseList.get(1);

        System.out.println("Online users: " + _onlineUsers);
</code></pre>

<p>And where I initialise it:</p>

<pre><code>private String _onlineUsers;
</code></pre>

<p>It seems it is only taking the first user and adding it to the list, I want to add them all to an arraylist.</p>

<p>EDIT: I have now tried it this way, with little difference:</p>

<pre><code>List &lt;String&gt; responseList = Arrays.asList(OnlineUsersPost.split(","));
    if (responseList.contains("RESP_USERLIST")){
        for (int i = 0; i &lt; responseList.size(); i++) {
            _onlineUsers.add(responseList.get(i));
            System.out.println("Online users: " + _onlineUsers);
        }
</code></pre>

<p>And where I initialise it:</p>

<pre><code>private List&lt;String&gt; _onlineUsers;
</code></pre>
