[android-developers] Re: items can't be selected (or highlighted)
Hi Andy, Sorry for the delay. I found a solution with the link below : http://www.anddev.org/extended_checkbox_list__extension_of_checkbox_text_list_tu-t5734.html I took a leaf out of this example. Hope taht will help you. Regards, Tom On 9 juil, 15:16, Andy Liu wrote: > hi Tom, > > I encountered the same problem you had. Did you find the solution to > the problem? > > thanks, > andy > > On Jun 3, 7:01 am, Tom wrote: > > > Ok first in my row.xml I had : > > - a TextView with the attribute "android:telephone" > > When I remove this attribute, the item can beselectedwith the mouse. > > > - a CheckBox : > > > android:layout_width="wrap_content" > > android:layout_height="wrap_content"/> > > > When I remove this CheckBox,itemsare selectable and clickable. > > > I'm looking for what is blocking. > > Best regards > > Tom > > > On 3 juin, 15:25, guna wrote: > > > > Then Check the xml Remove unnecessary attributes > > > > On Wed, Jun 3, 2009 at 6:37 PM, guna wrote: > > > > getListView().setItemsCanFocus(true); > > > > > Change to true as like this... it will work then > > > > > On Wed, Jun 3, 2009 at 6:23 PM, Tom wrote: > > > > >> public class UserList extends ListActivity implements > > > >> AdapterView.OnItemClickListener{ > > > > >> private Client client; > > > >> private ArrayList users = new ArrayList(); > > > >> 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) this.client.getUsers(); > > > > >> Log.i(getClass().getSimpleName(),"Display users"); > > > >> for(int j=0;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 { > > > > >> private LayoutInflater mInflater; > > > >> private ArrayListitems; > > > > >> public UserAdapter(Context context, int resourceId, > > > >> ArrayListitems) > > > >> { > > > >> 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() { > > > >> returnitems.size(); > > > >> } > > > > >> public User getItem(int position) { > > > >> if (0 == position) { > > > >> return null; > > > >> } > > > >> returnitems.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); > > > >> h
[android-developers] Re: items can't be selected (or highlighted)
Hi, No the TextView doesn't items with clickable links. On 3 juin, 04:16, Julian Shen wrote: > Does your TextView within items have clickable links? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: items can't be selected (or highlighted)
hi Tom, I encountered the same problem you had. Did you find the solution to the problem? thanks, andy On Jun 3, 7:01 am, Tom wrote: > Ok first in my row.xml I had : > - a TextView with the attribute "android:telephone" > When I remove this attribute, the item can beselectedwith the mouse. > > - a CheckBox : > android:layout_width="wrap_content" > android:layout_height="wrap_content"/> > > When I remove this CheckBox,itemsare selectable and clickable. > > I'm looking for what is blocking. > Best regards > Tom > > On 3 juin, 15:25, guna wrote: > > > Then Check the xml Remove unnecessary attributes > > > On Wed, Jun 3, 2009 at 6:37 PM, guna wrote: > > > getListView().setItemsCanFocus(true); > > > > Change to true as like this... it will work then > > > > On Wed, Jun 3, 2009 at 6:23 PM, Tom wrote: > > > >> public class UserList extends ListActivity implements > > >> AdapterView.OnItemClickListener{ > > > >> private Client client; > > >> private ArrayList users = new ArrayList(); > > >> 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) this.client.getUsers(); > > > >> Log.i(getClass().getSimpleName(),"Display users"); > > >> for(int j=0;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 { > > > >> private LayoutInflater mInflater; > > >> private ArrayListitems; > > > >> public UserAdapter(Context context, int resourceId, > > >> ArrayListitems) > > >> { > > >> 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() { > > >> returnitems.size(); > > >> } > > > >> public User getItem(int position) { > > >> if (0 == position) { > > >> return null; > > >> } > > >> returnitems.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.first
[android-developers] Re: items can't be selected (or highlighted)
Does your TextView within items have clickable links? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: items can't be selected (or highlighted)
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 : 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 wrote: > Then Check the xml Remove unnecessary attributes > > On Wed, Jun 3, 2009 at 6:37 PM, guna wrote: > > getListView().setItemsCanFocus(true); > > > Change to true as like this... it will work then > > > On Wed, Jun 3, 2009 at 6:23 PM, Tom wrote: > > >> public class UserList extends ListActivity implements > >> AdapterView.OnItemClickListener{ > > >> private Client client; > >> private ArrayList users = new ArrayList(); > >> 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) this.client.getUsers(); > > >> Log.i(getClass().getSimpleName(),"Display users"); > >> for(int j=0;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 { > > >> private LayoutInflater mInflater; > >> private ArrayList items; > > >> public UserAdapter(Context context, int resourceId, > >> ArrayList 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.get
[android-developers] Re: items can't be selected (or highlighted)
Then Check the xml Remove unnecessary attributes On Wed, Jun 3, 2009 at 6:37 PM, guna wrote: > getListView().setItemsCanFocus(true); > > Change to true as like this... it will work then > > On Wed, Jun 3, 2009 at 6:23 PM, Tom wrote: > >> >> public class UserList extends ListActivity implements >> AdapterView.OnItemClickListener{ >> >>private Client client; >>private ArrayList users = new ArrayList(); >>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) this.client.getUsers(); >> >> Log.i(getClass().getSimpleName(),"Display users"); >> for(int j=0;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 { >> >>private LayoutInflater mInflater; >>private ArrayList items; >> >>public UserAdapter(Context context, int resourceId, >> ArrayList 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 wrote: >> > Post your latest code... So that its easy to correct the errors >> Check >> > whether enabled the listite
[android-developers] Re: items can't be selected (or highlighted)
I'm sorry but it does'nt work. On 3 juin, 15:07, guna wrote: > getListView().setItemsCanFocus(true); > > Change to true as like this... it will work then > > On Wed, Jun 3, 2009 at 6:23 PM, Tom wrote: > > > public class UserList extends ListActivity implements > > AdapterView.OnItemClickListener{ > > > private Client client; > > private ArrayList users = new ArrayList(); > > 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) this.client.getUsers(); > > > Log.i(getClass().getSimpleName(),"Display users"); > > for(int j=0;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 { > > > private LayoutInflater mInflater; > > private ArrayList items; > > > public UserAdapter(Context context, int resourceId, > > ArrayList 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 wrote: > > > Post your latest code... So that its easy to correct the errors.
[android-developers] Re: items can't be selected (or highlighted)
getListView().setItemsCanFocus(true); Change to true as like this... it will work then On Wed, Jun 3, 2009 at 6:23 PM, Tom wrote: > > public class UserList extends ListActivity implements > AdapterView.OnItemClickListener{ > >private Client client; >private ArrayList users = new ArrayList(); >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) this.client.getUsers(); > > Log.i(getClass().getSimpleName(),"Display users"); > for(int j=0;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 { > >private LayoutInflater mInflater; >private ArrayList items; > >public UserAdapter(Context context, int resourceId, > ArrayList 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 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 wrote: > > > > > I added to my class "implements AdapterView.OnItemClickListener". > > > Then I implemented "onItemClickListener" method and added in > > > "onCreate" "setOnClickListener(this)". > > > > > Now I can select
[android-developers] Re: items can't be selected (or highlighted)
public class UserList extends ListActivity implements AdapterView.OnItemClickListener{ private Client client; private ArrayList users = new ArrayList(); 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) this.client.getUsers(); Log.i(getClass().getSimpleName(),"Display users"); for(int j=0;j adapterView, View view, int position, long id) { Log.d(getClass().getSimpleName(), " -- Click -- "); } // Adapter private class UserAdapter extends ArrayAdapter { private LayoutInflater mInflater; private ArrayList items; public UserAdapter(Context context, int resourceId, ArrayList 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 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 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 wrote: > > > Ask clearly your questions > > > > On Wed, Jun 3, 2009 at 4:45 PM, Tom wrote: > > > > > I just want to notice that the Layout for the ArrayAdapter contains > > > > checkbox. > > > > > On 3 juin, 11:33, Tom wrote: > > > > > Ok > > > > > I added to my class "implements AdapterView.OnItemClickListener". > > > > > Then I implemented "onItemClickListener" method and added in > > > > > "onCreate" "setOnClickListener(this)
[android-developers] Re: items can't be selected (or highlighted)
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 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 wrote: > > Ask clearly your questions > > > > On Wed, Jun 3, 2009 at 4:45 PM, Tom wrote: > > > > > I just want to notice that the Layout for the ArrayAdapter contains > > > checkbox. > > > > > On 3 juin, 11:33, Tom 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 wrote: > > > > > > > Tom, > > > > > > > You didnt implements OnItemClickListener, and also in oncreate add > > > > > setonitemclicklistener(this) > > > > > > > On Tue, Jun 2, 2009 at 8:10 PM, Tom > wrote: > > > > > > > > These are my line of codings : > > > > > > > > public class UserList extends ListActivity{ > > > > > > > >private Client client; > > > > > >private ArrayList users = new ArrayList(); > > > > > >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) this.client.getUsers(); > > > > > >for(int j=0;j > > > > >{ > > > > > >this.userAdapter.add(users.get(j)); > > > > > >} > > > > > >setListAdapter(this.userAdapter); > > > > > >} > > > > > >} > > > > > >} > > > > > > > >private class UserAdapter extends ArrayAdapter{ > > > > > > > >private LayoutInflater mInflater; > > > > > >private ArrayList items; > > > > > > > >public UserAdapter(Context context, int resourceId, > > > > > > ArrayList 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); > > > > > >
[android-developers] Re: items can't be selected (or highlighted)
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 wrote: > Ask clearly your questions > > On Wed, Jun 3, 2009 at 4:45 PM, Tom wrote: > > > I just want to notice that the Layout for the ArrayAdapter contains > > checkbox. > > > On 3 juin, 11:33, Tom 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 wrote: > > > > > Tom, > > > > > You didnt implements OnItemClickListener, and also in oncreate add > > > > setonitemclicklistener(this) > > > > > On Tue, Jun 2, 2009 at 8:10 PM, Tom wrote: > > > > > > These are my line of codings : > > > > > > public class UserList extends ListActivity{ > > > > > > private Client client; > > > > > private ArrayList users = new ArrayList(); > > > > > 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) this.client.getUsers(); > > > > > for(int j=0;j > > > > { > > > > > this.userAdapter.add(users.get(j)); > > > > > } > > > > > setListAdapter(this.userAdapter); > > > > > } > > > > > } > > > > > } > > > > > > private class UserAdapter extends ArrayAdapter{ > > > > > > private LayoutInflater mInflater; > > > > > private ArrayList items; > > > > > > public UserAdapter(Context context, int resourceId, > > > > > ArrayList 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); > > > > >
[android-developers] Re: items can't be selected (or highlighted)
Ask clearly your questions On Wed, Jun 3, 2009 at 4:45 PM, Tom wrote: > > I just want to notice that the Layout for the ArrayAdapter contains > checkbox. > > On 3 juin, 11:33, Tom 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 wrote: > > > > > Tom, > > > > > You didnt implements OnItemClickListener, and also in oncreate add > > > setonitemclicklistener(this) > > > > > On Tue, Jun 2, 2009 at 8:10 PM, Tom wrote: > > > > > > These are my line of codings : > > > > > > public class UserList extends ListActivity{ > > > > > >private Client client; > > > >private ArrayList users = new ArrayList(); > > > >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) this.client.getUsers(); > > > >for(int j=0;j > > >{ > > > >this.userAdapter.add(users.get(j)); > > > >} > > > >setListAdapter(this.userAdapter); > > > >} > > > >} > > > >} > > > > > >private class UserAdapter extends ArrayAdapter{ > > > > > >private LayoutInflater mInflater; > > > >private ArrayList items; > > > > > >public UserAdapter(Context context, int resourceId, > > > > ArrayList 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.phon
[android-developers] Re: items can't be selected (or highlighted)
I just want to notice that the Layout for the ArrayAdapter contains checkbox. On 3 juin, 11:33, Tom 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 wrote: > > > Tom, > > > You didnt implements OnItemClickListener, and also in oncreate add > > setonitemclicklistener(this) > > > On Tue, Jun 2, 2009 at 8:10 PM, Tom wrote: > > > > These are my line of codings : > > > > public class UserList extends ListActivity{ > > > > private Client client; > > > private ArrayList users = new ArrayList(); > > > 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) this.client.getUsers(); > > > for(int j=0;j > > { > > > this.userAdapter.add(users.get(j)); > > > } > > > setListAdapter(this.userAdapter); > > > } > > > } > > > } > > > > private class UserAdapter extends ArrayAdapter{ > > > > private LayoutInflater mInflater; > > > private ArrayList items; > > > > public UserAdapter(Context context, int resourceId, > > > ArrayList 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; > > > } > > > > private class ViewHolder { >