Thank you so much. On Nov 16, 8:32 am, nikki <[email protected]> wrote: > As far as I know ListView doesn't support setting selection by > clicking under touchmode, but I also remember you can get onItemClick > listener > invoked by turnning the focus of your list item and its children off > > > > lau ka man wrote: > > As I mentioned in the email subject, > > I want toselectan item (e.g. Department of Human Resource Management) in > > my ListView. > > And you can see that: > > I had try to use > > setClickable(true), setChoiceMode(ListView.CHOICE_MODE_SINGLE), > > setFocusable(true), setFocusableInTouchMode(true), > > no matter I use touch screen toclickon the item or use the scroll ball on > > my mouse toselectthe item, it also doesn't work. > > Is there any mistakes in my coding? > > I hope someone can give me some ideas what I should do. > > because I am a beginner for developing Android application. > > > And the following is my coding: > > package com.example.abc; > > > import android.app.ListActivity; > > import android.content.Intent; > > import android.os.Bundle; > > import android.view.View; > > import android.view.View.OnClickListener; > > import android.widget.ArrayAdapter; > > import android.widget.ListView; > > > public class DeptList extends ListActivity { > > int position; > > /** Called when the activity is first created. */ > > @Override > > public void onCreate(Bundle bund) { > > super.onCreate(bund); > > > setListAdapter(new ArrayAdapter<String>(this, > > android.R.layout.simple_list_item_1, DEPARTMENTS)); > > getListView().setTextFilterEnabled(true); > > getListView().setClickable(true); > > getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); > > getListView().setFocusable(true); > > getListView().setFocusableInTouchMode(true); > > getListView().setOnClickListener(selectItem); > > } > > > private OnClickListener selectItem = new OnClickListener() > > { > > public void onClick(View v) > > { > > position = getListView().getCheckedItemPosition(); > > if(position == 2) > > { > > Intent contactlist = new Intent(); > > contactlist.setClass(DeptList.this, Meeting.class); > > startActivity(contactlist); > > } > > else > > { > > Intent contactlist1 = new Intent(); > > contactlist1.setClass(DeptList.this, OfficeMap.class); > > startActivity(contactlist1); > > } > > } > > }; > > > static final String[] DEPARTMENTS = new String[] { > > "Department of Accounting", > > "Department of Marketing and Sales", > > "Department of Human Resource Management", > > "Department of Computing" > > }; > > }- Hide quoted text - > > - Show quoted text -
-- You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en

