custom added image in a listview changes its position on listview items add
<p>I am creating a chat application for a website.As soon as anyone comes on the website a notification is sent with their name to the site admin that this guy has arrived on your site.</p>

<p>Now in the application there are two activity one for client and admin chat and other for the list of client arriving on the site which keeps on updating as clients arrive.if the admin clicks on a name in the client list activity a green dot is placed in front of his name indicating the admin that you are currently chatting with this guy.Multiple dots will be placed in different areas of that clientlist as the admin will click on them.To help admin remember who he had been talking with.</p>

<p>The problem is that if i run the app and the first client arrives in the clientlist.I click on his name and I am taken to chatpage(That's fine).I go back and I see a green dot placed in front of it.But while on the clientlist activity as the third person  arrive and the clientlist adds him (remember I've only clicked the first one i.e the dot is present in front of the first item of clientlist at 0 position) my green dot moves down from position 0 to position 1 automatically.</p>

<p>I don't know why this is happening.</p>

<p>Here's how Ip is sent to the clientlist activity as a notification.</p>

<pre><code>Intent i=new Intent("android.intent.action.GET_IP").putExtra("ClientIp", ip);
this.sendBroadcast(i); 
</code></pre>

<p>And here's how I recieve it in the clientlist activity and forward it to my <code>lazyadapter</code> class to add it in the listview.</p>

<pre><code>mReceiver=new BroadcastReceiver() {

    @Override
    public void onReceive(Context context, Intent intent) {

    if(!ParseXML.ConfirmIpExistance(adapter.iplist, intent.getExtras().getString("ClientIp")))
    {
        adapter.InsertIntoExistingClients(intent.getExtras().getString("ClientIp"));
    }
  }
};
</code></pre>

<p>This is the LazyAdapter function to insert in client listview.</p>

<pre><code>public void InsertIntoExistingClients(String ip)    //runs when you are on the clientlistactivity to insert only one item.
{       
    this.iplist.add(ip);
    this.notifyDataSetChanged();
}
</code></pre>

<p>When the admin clicks on a client name in clientlist activity his listview position is sent to the next activity.In the next activity(chatpage) it is checked if other admin is already talking with that client and if it is true <code>OnActivityResult</code> is called of the previous activity with a code telling it not to insert an image because this admin is not talking to that client which he has clicked.But if no other admin is talking this means.He can talk.So a code and the listview position(recieved from the previous activity when user clicked the client name) is sent back in the <code>OnActivityResult</code> and it places the image in front of its name in the listview.</p>

<p>Here's how this is going on.
OnListViewItemClick:</p>

<pre><code>  lv.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView&lt;?&gt; adapter, View view, int position,long id) {

                try {

                    selectedPeople.add(position);

                    TextView tv=(TextView)view.findViewById(R.id.clientip);

                    Intent i=new Intent(getApplicationContext(),ChatPageActivity.class);
                    i.putExtra("AdminEmail",ClientListActivity.AdminEmail);
                    i.putExtra("ClientIp",tv.getText().toString());
                    i.putExtra("ChildAt", position);

                    startActivityForResult(i, 200);
                }
                catch(Exception e)
                {
                    Log.e("erora",e.getMessage());
                }
            }
        }); 
</code></pre>

<p>Here's how I accept the answer in my <code>onAcvitityResult</code>:</p>

<pre><code>    @Override
protected void onActivityResult(int requestCode,int resultCode,Intent data)
{
    try {
    super.onActivityResult(requestCode, resultCode, data);
    if(resultCode!= 23)
    {
        ImageView imageView=(ImageView)lv.getChildAt(data.getExtras().getInt("ChildAt")).findViewById(R.id.onlineImg);
        imageView.setImageResource(R.drawable.online);
    }

}catch(Exception e)
{
    Log.e("ClientList_onActivityResult",e.getMessage());
}

}
</code></pre>

<p>Result code 23 will only be sent if a client is already talking to other admin rather than this admin.In the end the question is that how do I able to stop this i.e the green dot automatically changes its position from 0 to 1 in the listview.</p>
