0

I am displaying list in my apps. when user can click on list it will send to next activity. list is displayed properly but list is clickable on version less than 3.0 and not clickable on version greater than 3.0. I don't understand where i am wrong. i'm using listfragment for displaying list and override method onListItemClick. i tried some solution on stackoverflow but not achive my goal. Please does anyone have solution.

following is the onListItemClick method from listfragment.

@Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        // TODO Auto-generated method stub
        super.onListItemClick(l, v, position, id);
        l.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View view, int arg2,
                    long arg3) {
                Intent href = new Intent(getSherlockActivity(), ProjectDetailActivity.class);

                String projId = ((TextView) view.findViewById(R.id.projectId)).getText().toString();
                String projName = ((TextView) view.findViewById(R.id.projectName)).getText().toString();
                Log.v("in itemclickListener", "click"+((TextView) view.findViewById(R.id.projectId)).getText().toString());

                getSherlockActivity().startActivity(href);
            }
        });
    }

Following is the listview.xml

<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="1dp"
    android:divider="@drawable/divider"   
    android:smoothScrollbar="true"
    android:dividerHeight="1dp"
    android:scrollbarThumbVertical="@drawable/divider" 
    android:drawSelectorOnTop="false"
    android:listSelector="@drawable/list_selector"
    android:clickable="true"
    >
</ListView>
nilesh wani
  • 1,261
  • 5
  • 18
  • 30

1 Answers1

3

I think the following way is enough.

listview.setOnItemClickListener(new OnItemClickListener() {

    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
       // TODO Auto-generated method stub
    }
});

remove the onListItemClick() method and write this way in oncreate() method itself.

I hope this will help you.

Gunaseelan
  • 14,415
  • 11
  • 80
  • 128