These items are not selectable and focusable, these are just lists
that use ListView's choice mode. Like I already told you.

On Fri, Jun 5, 2009 at 2:03 AM, Tom<thomas.coz...@gmail.com> wrote:
>
> Hi,
>
> Maybe my question wasn't clear 'cause I see in Android some item's
> selectable and focusable wich contains checkbox.
> Indeed, for instance, in "Settings > Wireless controls". Wi-fi,
> Bluetooth and Airplane Mode items contain each a checkbox and they are
> selectable and focusable.
>
> I will look for a solution and will post it.
>
> Best Regards
> Tom
>
> On 4 juin, 17:45, Romain Guy <romain...@google.com> wrote:
>> Please stop bumping threads if you don't get an answer right away.
>>
>> And the answer to your question is no. Use listview's choice mode.
>>
>>
>>
>> On Thu, Jun 4, 2009 at 7:31 AM, Tom <thomas.coz...@gmail.com> wrote:
>>
>> > I'm still looking for some answers :p
>>
>> > On 4 juin, 10:29, Tom <thomas.coz...@gmail.com> wrote:
>> >> Thanks for your reply.
>>
>> >> In fact I want that each items are focusable and selectable AND
>> >> checkboxes only selectable.
>> >> I want to add a context menu for each items.
>>
>> >> Is it possible?
>>
>> >> On 3 juin, 19:29, Romain Guy <romain...@google.com> wrote:
>>
>> >> > You can't, it's one or the other. If you put a focusable widget in a
>> >> > list item, that's what happens. If you need checkboxes, use ListView's
>> >> > choice mode instead.
>>
>> >> > On Wed, Jun 3, 2009 at 10:25 AM, Tom <thomas.coz...@gmail.com> wrote:
>>
>> >> > > Hi,
>> >> > > One of my ListView's has a CheckBox on every item's RelativeLayout.
>>
>> >> > > I just found that clicking on any item of the ListView does not
>> >> > > callback its OnItemClick().
>>
>> >> > > If I remove the CheckBox from item layout, callback is ok then.
>>
>> >> > > My app needs to get both callbacks from the CheckBox as well as from
>> >> > > "the other area" of a ListView item.
>>
>> >> > > I read
>> >> > >http://android-developers.blogspot.com/2008/12/touch-mode.html
>> >> > > But I'm a bit confuse.
>>
>> >> > > Can anybody advise me how I get the callback on the ListView with
>> >> > > CheckBox?
>>
>> >> > > public class UserList extends ListActivity implements
>> >> > > ListView.OnItemClickListener, ListView.OnClickListener{
>>
>> >> > >        private Client client;
>> >> > >        private ArrayList<User> users = new ArrayList<User>();
>> >> > >        private UserAdapter userAdapter;
>>
>> >> > >   �...@override
>> >> > >    public void onCreate(Bundle savedInstanceState) {
>> >> > >        super.onCreate(savedInstanceState);
>> >> > >        setContentView(R.layout.user_list);
>>
>> >> > >        getListView().setOnItemClickListener(this);
>>
>> >> > >        Intent i = getIntent();
>> >> > >        if (i!= null)
>> >> > >        {
>> >> > >                if (i.getAction().equalsIgnoreCase(Intent.ACTION_VIEW))
>> >> > >                {
>> >> > >                this.client = (Client) i.getSerializableExtra
>> >> > > (Constants.CLIENT_CLASS_NAME);
>>
>> >> > >                this.userAdapter = new UserAdapter(this,
>> >> > > R.layout.user_row, users);
>>
>> >> > >                users = (ArrayList<User>) this.client.getUsers();
>>
>> >> > >                Log.i(getClass().getSimpleName(),"Display users");
>> >> > >                for(int j=0;j<users.size();j++)
>> >> > >                {
>> >> > >                        this.userAdapter.add(users.get(j));
>> >> > >                }
>> >> > >                setListAdapter(this.userAdapter);
>>
>> >> > >                }
>> >> > >        }
>> >> > >    }
>>
>> >> > >   �...@override
>> >> > >    public void onItemClick(AdapterView<?> adapterView, View view, int
>> >> > > position, long id)
>> >> > >    {
>> >> > >        Log.d(getClass().getSimpleName(), " -- Click on User item -- 
>> >> > > ");
>> >> > >    }
>>
>> >> > >    private class UserAdapter extends ArrayAdapter<User> {
>>
>> >> > >        private LayoutInflater mInflater;
>> >> > >        private ArrayList<User> items;
>>
>> >> > >        public UserAdapter(Context context, int resourceId,
>> >> > > ArrayList<User> items)
>> >> > >        {
>> >> > >                super(context, resourceId, items);
>> >> > >            mInflater = LayoutInflater.from(context);
>> >> > >                this.items = items;
>> >> > >        }
>>
>> >> > >        public boolean areAllItemsSelectable()
>> >> > >        {
>> >> > >            return true;
>> >> > >        }
>>
>> >> > >        public boolean isEnabled(int position) {
>> >> > >            if (position >= 0 && position <= items.size()) {
>> >> > >                return true;
>> >> > >            }
>> >> > >            return false;
>> >> > >        }
>>
>> >> > >        public int getCount() {
>> >> > >            return items.size();
>> >> > >        }
>>
>> >> > >        public User getItem(int position) {
>> >> > >              if (0 == position) {
>> >> > >                  return null;
>> >> > >              }
>> >> > >              return items.get(position);
>> >> > >         }
>>
>> >> > >       �...@override
>> >> > >        public View getView(int position, View convertView, ViewGroup
>> >> > > parent) {
>> >> > >            // A ViewHolder keeps references to children views to
>> >> > > avoid unnecessary calls
>> >> > >            // to findViewById() on each row.
>> >> > >            ViewHolder holder = null;
>> >> > >            View v = convertView;
>> >> > >            User user = items.get(position);
>>
>> >> > >            if (v == null) {
>> >> > >                mInflater = (LayoutInflater)getSystemService
>> >> > > (Context.LAYOUT_INFLATER_SERVICE);
>> >> > >                v = mInflater.inflate(R.layout.user_row, null);
>>
>> >> > >                    if (user != null) {
>> >> > >                        // Creates a ViewHolder and store references 
>> >> > > to the
>> >> > > children views
>> >> > >                        // we want to bind data to.
>> >> > >                        holder = new ViewHolder();
>> >> > >                        holder.firstNameText = (TextView) 
>> >> > > v.findViewById
>> >> > > (R.id.user_first_name);
>> >> > >                        holder.lastNameText = (TextView) v.findViewById
>> >> > > (R.id.user_last_name);
>> >> > >                        holder.phoneNumberText = (TextView) 
>> >> > > v.findViewById
>> >> > > (R.id.user_phone_number);
>> >> > >                        holder.statusText = (TextView) v.findViewById
>> >> > > (R.id.user_status);
>> >> > >                    }
>>
>> >> > >                    v.setTag(holder);
>> >> > >            }
>> >> > >                else
>> >> > >                {
>> >> > >                        // Get the ViewHolder back to get fast access 
>> >> > > to the
>> >> > > TextView
>> >> > >                // and the ImageView.
>> >> > >                holder = (ViewHolder) v.getTag();
>> >> > >                }
>>
>> >> > >            if (holder.firstNameText != null) {
>> >> > >                holder.firstNameText.setText(user.getFirstName());
>> >> > >            }
>> >> > >            if (holder.lastNameText != null){
>> >> > >                holder.lastNameText.setText(user.getLastName());
>> >> > >            }
>> >> > >            if ( holder.phoneNumberText != null){
>> >> > >                 holder.phoneNumberText.setText(user.getPhoneNumber());
>> >> > >            }
>> >> > >            if (holder.statusText != null){
>> >> > >                holder.statusText.setText(String.valueOf(user.getStatus
>> >> > > ()));
>> >> > >            }
>>
>> >> > >            return v;
>> >> > >        }
>>
>> >> > >        class ViewHolder {
>> >> > >            TextView firstNameText;
>> >> > >            TextView lastNameText;
>> >> > >            TextView phoneNumberText;
>> >> > >            TextView statusText;
>>
>> >> > >        }
>>
>> >> > >    }
>>
>> >> > > Best regards
>> >> > > Tom
>>
>> >> > --
>> >> > Romain Guy
>> >> > Android framework engineer
>> >> > romain...@android.com
>>
>> >> > Note: please don't send private questions to me, as I don't have time
>> >> > to provide private support.  All such questions should be posted on
>> >> > public forums, where I and others can see and answer them
>>
>> --
>> Romain Guy
>> Android framework engineer
>> romain...@android.com
>>
>> Note: please don't send private questions to me, as I don't have time
>> to provide private support.  All such questions should be posted on
>> public forums, where I and others can see and answer them
> >
>



-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to