As I mentioned in the email subject,
I want to select an 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 to click on the item or use the scroll ball on
my mouse to select the 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"
    };
}

-- 
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