Android ListView with Checkbox and all clickable?

Up vote 8 down vote favorite 3 share g+ share fb share tw.

I want to use a ListView with the items having following layout ------------------------- CB TV TV ------------------------- CB is a checkbox and TV is a Textview. Now i've read somewhere that you can't have clickable items in a ListView. If you have some then you won't be able to click on the ListItems.

But if I look at the GoogleMail app, this is possible. I can mark several messages with the checkbox (and then select an action for them) or I can click on the ListItem (or scroll with the dpad) to get to another screen. Does someone has code/example how this is possible?

Android listview checkbox focus link|improve this question asked Mar 24 '11 at 9:54codie471183125 25% accept rate.

Look at the code here You can select multiple items in listview. Check here With Text and Image example : here.

Below code will help you : public class DeckListAdapter extends BaseAdapter{ private LayoutInflater mInflater; ArrayList teams=new ArrayList(); ArrayList teamcolor=new ArrayList(); public DeckListAdapter(Context context) { // Cache the LayoutInflate to avoid asking for a new one each time. MInflater = LayoutInflater. From(context); teams.

Add("Upload"); teams. Add("Download"); teams. Add("Device Browser"); teams.

Add("FTP Browser"); teams. Add("Options"); teamcolor. Add(Color.

WHITE); teamcolor. Add(Color. LTGRAY); teamcolor.

Add(Color. WHITE); teamcolor. Add(Color.

LTGRAY); teamcolor. Add(Color. WHITE); } public int getCount() { return teams.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } @Override public View getView(final int position, View convertView, ViewGroup parent) { final ViewHolder holder; if (convertView == null) { convertView = mInflater.

Inflate(R.layout. Decklist, null); holder = new ViewHolder(); holder. Icon = (ImageView) convertView.

FindViewById(URL1. Deckarrow); holder. Text = (TextView) convertView. FindViewById(R.id.

Textname); .......here you can use holder.text. Setonclicklistner(new View.onclick. For each textview System.out.

Println(holder.text.getText().toString()); convertView. SetTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.text. SetText(teams.

Get(position)); if(position Get(position)); holder.icon. SetImageResource(R.drawable. Arraocha); return convertView; } class ViewHolder { ImageView icon; TextView text; } } Hope this helps..

I don't have the code atm but it is possible because move, drag, click & longClick is not the same event. And also the hitbox of the checkbox is on top of the listview.

Set the listview adapter to "simple_list_item_multiple_choice" ArrayAdapter adapter; List values; // put values in this //Put in listview adapter = new ArrayAdapter( this, android.R.layout. Simple_list_item_multiple_choice, values); setListAdapter(adapter).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions