Android ListView with CheckBox - The easy way
After MUCH Googling for a simple way to add a checkbox to a listview, I finally found an example in the ApiDemos that come with the SDK. If your looking for this end outcome, then read on. Auto Uploader The "Enabled" with CheckBox above is actually a ListView, within a regular Activity, with just one item in the list. First, simply add the ListView to your xml layout (main.xml): < ListView android:id = "@+id/listView1" android:layout_width = "match_parent" android:layout_height = "wrap_content" > </ ListView > Second, in your Activity, define a String[] of items (just one for me), and wire up the ListView into a variable. List so in my onCreate(): ListView listView1 ; String[] listItems = { "Enabled" }; listView1 = (ListView)findViewById(R.id. listView1 ); listView1 .setAdapter( new ArrayAdapter<String>( this , android.R.layout. simple_list_...
Comments
Post a Comment