Ok first in my row.xml I had :
 - a TextView with the attribute "android:telephone"
When I remove this attribute, the item can be selected with the mouse.

 - a CheckBox :
    <CheckBox android:id="@+id/user_check"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

When I remove this CheckBox, items are selectable and clickable.

I'm looking for what is blocking.
Best regards
Tom

On 3 juin, 15:25, guna <gunaz...@gmail.com> wrote:
> Then Check the xml.... Remove unnecessary attributes........
>
> On Wed, Jun 3, 2009 at 6:37 PM, guna <gunaz...@gmail.com> wrote:
> >  getListView().setItemsCanFocus(true);
>
> > Change to true as like this... it will work then
>
> > On Wed, Jun 3, 2009 at 6:23 PM, Tom <thomas.coz...@gmail.com> wrote:
>
> >> public class UserList extends ListActivity implements
> >> AdapterView.OnItemClickListener{
>
> >>        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().setItemsCanFocus(false);
> >>        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 -- ");
> >>    }
>
> >>    // Adapter
> >>     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) {
>
> >>            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
> >> two 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
> >>                {
> >>                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;
> >>        }
>
> >>        public long getItemId(int position) {
> >>            return position;
> >>        }
>
> >>    }
>
> >> On 3 juin, 13:35, guna <gunaz...@gmail.com> wrote:
> >> > Post your latest code... So that its easy to correct the errors....
> >> Check
> >> > whether enabled the listitems.....
>
> >> > On Wed, Jun 3, 2009 at 4:59 PM, Tom <thomas.coz...@gmail.com> wrote:
>
> >> > > I added to my class "implements AdapterView.OnItemClickListener".
> >> > > Then I implemented "onItemClickListener" method and added in
> >> > > "onCreate" "setOnClickListener(this)".
>
> >> > > Now I can select and highlight items but only with the trackball.
> >> > > Nothing happens with the mouse event.
>
> >> > > On 3 juin, 13:23, guna <gunaz...@gmail.com> wrote:
> >> > > > Ask clearly your questions........
>
> >> > > > On Wed, Jun 3, 2009 at 4:45 PM, Tom <thomas.coz...@gmail.com>
> >> wrote:
>
> >> > > > > I just want to notice that the Layout for the ArrayAdapter
> >> contains
> >> > > > > checkbox.
>
> >> > > > > On 3 juin, 11:33, Tom <thomas.coz...@gmail.com> wrote:
> >> > > > > > Ok
> >> > > > > > I added to my class "implements
> >> AdapterView.OnItemClickListener".
> >> > > > > > Then I implemented "onItemClickListener" method and added in
> >> > > > > > "onCreate" "setOnClickListener(this)".
>
> >> > > > > > Now I can select and highlight items but only with the
> >> trackball.
> >> > > > > > Nothing happens with the mouse event.
>
> >> > > > > > May have implement "OnItemSelectedListener" too ?
>
> >> > > > > > Thanks
> >> > > > > > Tom
>
> >> > > > > > On 2 juin, 16:47, guna <gunaz...@gmail.com> wrote:
>
> >> > > > > > > Tom,
>
> >> > > > > > > You didnt implements OnItemClickListener, and also in oncreate
> >> add
> >> > > > > > > setonitemclicklistener(this)....
>
> >> > > > > > > On Tue, Jun 2, 2009 at 8:10 PM, Tom <thomas.coz...@gmail.com>
> >> > > wrote:
>
> >> > > > > > > > These are my line of codings :
>
> >> > > > > > > > public class UserList extends ListActivity{
>
> >> > > > > > > >    private Client client;
> >> > > > > > > >    private ArrayList<User> users = new ArrayList<User>();
> >> > > > > > > >    private UserAdapter userAdapter;
> >> > > > > > > >    public static final int MENU_ITEM_VIEW = Menu.FIRST;
> >> > > > > > > >    private static final int COLUMN_INDEX_TITLE = 1;
>
> >> > > > > > > >   �...@override
> >> > > > > > > >    public void onCreate(Bundle savedInstanceState) {
> >> > > > > > > >        super.onCreate(savedInstanceState);
> >> > > > > > > >        setContentView(R.layout.user_list);
>
> >> > > > > > > >        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();
> >> > > > > > > >                for(int j=0;j<users.size();j++)
> >> > > > > > > >                {
> >> > > > > > > >                        this.userAdapter.add(users.get(j));
> >> > > > > > > >                }
> >> > > > > > > >                setListAdapter(this.userAdapter);
> >> > > > > > > >                }
> >> > > > > > > >        }
> >> > > > > > > >    }
>
> >> > > > > > > >    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);
> >> > > > > > > >         }
>
> ...
>
> plus de détails »
--~--~---------~--~----~------------~-------~--~----~
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