Wednesday 21 May 2014

ListView with checkbox

ListView with checkbox


                                       

1)Create a new android application project in eclipse 

2)Then after craeting a new project you have to edit the activity_mail.xml file , As shown below
                                                     

3)After editing the activity_main.xml file now you have to code the main activity  file as shown below
        
                           
Main Activity

package com.mobileapptech.listcheck;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends ActionBarActivity {

String[] country = new String[] {
   "micromax",
   "samsung",
   "nokia",
   "xolo",
   "lenovo",
   "sony",
   "htc",
   "lg",
   "lava",
   "ericsson"
};
   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);
       ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_multiple_choice, country);
       
       ListView listView = (ListView) findViewById(R.id.listview);
       listView.setAdapter(adapter);
       listView.setTextFilterEnabled(true);
   }



 4)Now the ListView with checkbox  is ready

                                                           
 


0 comments:

Post a Comment

Total Pageviews

Contact Form

Name

Email *

Message *

Mobile App Developer