2013-02-08 2 views
0

J'ai fait une application qui permettrait de récupérer tous les contacts stockés.Je veux faire une application qui permettra à l'utilisateur de sélectionner les contacts qu'il veut ajouter à l'application. Devrais-je créer des cases à cocher dynamiquement et récupérer les contacts sélectionnés ou existe-t-il un autre moyen de le faire?sélection de contacts

Répondre

0

ceci est un exemple, comme comme u besoin de travailler

 // MainActivity 

     public class MainActivity extends Activity { 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    final ListView listTags = (ListView) findViewById(R.id.listPack); 
    listTags.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, mStrings)); 
    listTags.setOnItemClickListener(new OnItemClickListener() { 

     @Override 
     public void onItemClick(AdapterView<?> parent, View view, 
       int position, long id) { 
      listTags.setSelection(position); 

// Toast.makeText (getParent(), "bonjour", Toast.LENGTH_LONG) .show(); } });

// principal xml

<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello" /> 

<ListView 
    android:id="@+id/listPack" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_marginBottom="5dip" 
    android:layout_marginLeft="5dip" 
    android:layout_marginRight="5dip" 
    android:layout_weight="1" > 
</ListView> 

    </LinearLayout> 

// // list_item.xml mise en page

+0

pourrait vous s'il vous plaît me donner une brève explication de votre Je ne suis pas capable de le comprendre. –

+0

voir ce http://thinkandroid.wordpress.com/2010/01/09/simplecursoradapters-and-listviews/ – Rohit

Questions connexes