Android listview
<p>Any one can help me in listview the first item should be selected by default </p>

<pre><code>package com.globalscholar.announcement;

import java.util.ArrayList;

import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.AdapterView.OnItemClickListener;

import com.globalscholar.R;

public class PublishAnnouncement extends ListActivity implements OnClickListener, OnItemClickListener{
    private ListView lViewPub;
    private String lv_items[] = {"Teachers" , "Students", "Administration"};
    RadioButton radioSSP;
    RadioButton radioPubAll1;
    Button backPub;
    Button donePub;
    int role = 0;

    //venkat
    int selectedPublishOption = -1;
    AudienceWrapper audienceDetails = null; 

    ArrayList&lt;Boolean&gt; checkedStates = new ArrayList&lt;Boolean&gt;();
    boolean checkedArray[];

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.publishannouncement);

    backPub=(Button)findViewById(R.id.buttPubBack);
    backPub.setOnClickListener(this);

    donePub=(Button)findViewById(R.id.buttPubDone);
    donePub.setOnClickListener(this);

    radioSSP=(RadioButton)findViewById(R.id.radioPubSSM);
    radioSSP.setOnClickListener(this);

    radioPubAll1=(RadioButton)findViewById(R.id.radioPubAll);
    radioPubAll1.setOnClickListener(this);
    radioPubAll1.setChecked(true);


    lViewPub = (ListView) findViewById(android.R.id.list);
    lViewPub.setOnItemClickListener(this);
    //  Set option as Multiple Choice. So that user can be able to select more the one option from list
    lViewPub.setAdapter(new ArrayAdapter&lt;String&gt;(this,
            R.layout.announcementlistviewstyle, lv_items));
    lViewPub.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    lViewPub.setVerticalScrollBarEnabled(false);
    getListView().setSelection(0);
    //venkat
    Bundle b = getIntent().getExtras();

    checkedStates.add(0, false);
    checkedStates.add(1, false);
    checkedStates.add(2, false);

    if(b!= null){
        audienceDetails = (AudienceWrapper) b.getSerializable("audienceDetails");
        selectedPublishOption = b.getInt("selectedPublishOption");
        //  checked = b.getLongArray("selectedPublishOptionsList");
        checkedArray =b.getBooleanArray("selectedPublishOptionsList");
        if(checkedArray!=null){
            Log.d("PA","Bundle Checked Array Size :"+checkedArray.length);
            for(int i=0;i&lt;checkedArray.length;i++){
                checkedStates.set(i, checkedArray[i]);
                Log.w("PA","CheckedStatus index:"+i+"Status"+checkedStates.get(i));
                if(checkedStates.get(i))
                    lViewPub.setItemChecked(i, true);
            }
        }

        Log.d("selected publishoption in PublishAnnouncement---&gt;", selectedPublishOption+"");
        if(selectedPublishOption == 0){
            radioPubAll1.setChecked(false);
            radioSSP.setChecked(true);
            lViewPub.setVisibility(BIND_AUTO_CREATE);
            //for checking the options                  
        }
    }
    //venkatend
    PublishAnnouncement.this.getListView().setOnItemClickListener(this);
}



public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position,
        long arg3) {        
    Log.d("onItemClick position in PublishAnnouncement-----&gt;",position+"");
    //role value updated in wrong way when u double click on Item
    //solved role problem in done button
    /* if(position == 0){
         role+= 4;
     }
     else if(position == 1){
         role+=8;
     }
     else if(position == 2){
         role+=2;
     }else{
         role+=14;
     }  
     Log.d("PA","Role :"+role);*/

    //venkat for selected publishes
    boolean currentlyChecked = checkedStates.get(position);  
    checkedStates.set(position, !currentlyChecked); 
    if(checkedArray!=null)
        checkedArray[position] = !currentlyChecked;



}

public void onClick(View v) {

    switch (v.getId()) {
    case R.id.radioPubSSM:
        lViewPub.setVisibility(BIND_AUTO_CREATE);
        break;
    case R.id.buttPubBack:
        onKeyDown(KeyEvent.KEYCODE_BACK, 
                new KeyEvent(KeyEvent.ACTION_DOWN,
                        KeyEvent.KEYCODE_BACK));
        break;
    case R.id.buttPubDone:
        //venkat
        int allSelect = 0;
        int sppCount=0;
        //venkatend
        Intent newPubDone= new Intent(PublishAnnouncement.this,Audience.class);
        Bundle b = new Bundle();
        if(radioPubAll1.isChecked()){
            role = 14;
            //venkat
            allSelect = 1;
        }else if(radioSSP.isChecked()){
            int len = checkedStates.size();     
            if(checkedArray == null)
                checkedArray = new boolean [len];
            for(int i=0;i&lt;len;i++){
                checkedArray[i] = checkedStates.get(i);
                if(checkedStates.get(i)==true){
                    sppCount++;
                }
            }
            Log.d("PA","Count :"+sppCount);
        }
        if(sppCount==0 &amp;&amp; radioSSP.isChecked()){
            AlertDialog.Builder alertBox = new AlertDialog.Builder(this);
            alertBox.setMessage("Please select Specific Memebers");
            alertBox.setNeutralButton("Ok", null);
            alertBox.show();

        }else{
            b.putInt("SelectedPublishOption", allSelect);
            int finalRole = 0;
            if(allSelect== 0){
                // b.putLongArray("SelectedPublishOptionsList", checked);
                b.putBooleanArray("SelectedPublishOptionsList", checkedArray);
                if(checkedArray!=null){
                    if(checkedArray[0]){
                        finalRole+=4;
                    }
                    if(checkedArray[1]){
                        finalRole+=8;
                    }
                    if(checkedArray[2]){
                        finalRole+=2;
                    }
                }
                Log.d("PA","After selecting final Role Value :"+finalRole);
                if(audienceDetails!=null)
                    audienceDetails.setRoleValue(finalRole);

            }
            b.putInt("role", finalRole);
            //venkatend
            newPubDone.putExtras(b);
            setResult(RESULT_OK, newPubDone);
            System.out.println("Role value is" + role);
            finish();

        }
        break;
    case R.id.radioPubAll:
        lViewPub.setVisibility(-1);

        //venkat testing logic
        if(checkedArray!=null){
            int len= checkedArray.length;
            if(len &gt; 0){
                for(int i=0;i&lt;len;i++){                             
                    lViewPub.setItemChecked(i, false);
                    System.out.println("all selected Position selected "+checkedArray[i]);
                }
            }
        }
        break;
    default:
        break;
    }
}
}
</code></pre>

<p>thanks </p>
