Please ignore this question.
I think i found my problem.
I had forgotten to set the background of the ListView item (item.xml
in this case).
Added the android:background="@android:drawable/menuitem_background"
and then i could get the focus for all my ListView Items.

Thanks.



On May 3, 11:14 pm, droid-stricken <harik...@gmail.com> wrote:
> Hi,
>
> There seems to be a lot of questions on this very issue. I have gone
> thro' most of them and yet unable to find a workable solution :(
>
> I am unable to get the focus on any item of my list. My Activity DOES
> NOT extend ListActivity and i do not have any ListView with default ID
> - android.R.id.list since i have more than one ListViews to deal with
> in my activity.
>
> The following is the relevant code from my ListAdapter.
>
> There seems to be this problem whenever i attempt to use
> convertView.setOnClickListener() instead of the standard
> listViewInstance.setOnItemClickListener() to react to the user's click
> on the list items. Why is that? I am forced to use
> convertView.setOnClickListener() under some circumstances because
> listViewInstance.setOnItemClickListener() does not seem to work under
> those cases. Trying to understand the basic difference between the two
> cases. Interestingly, i am able to detect the click event and the
> convertView.setOnClickListener() gets called - on the second attempt
> though - i don't know what's happening to the first click event. Any
> ideas or links to materials?
>
> public class MyListAdapter extends BaseAdapter {
>
>         protected static final String TAG = "MyListAdapter";
>         private LayoutInflater mInflater;
>         private Context mContext;
>
>         public MyListAdapter(MainActivity mainActivity) {
>                 // TODO Auto-generated constructor stub
>                 mContext = mainActivity;
>                 mInflater = LayoutInflater.from(mainActivity);
>         }
>
>         @Override
>         public View getView(int position, View convertView, ViewGroup parent)
> {
>                 // TODO Auto-generated method stub
>         ViewItemHolder holder;
>         if (convertView == null) {
>             convertView = mInflater.inflate(R.layout.item, null);
>             convertView.setClickable(true);
>             convertView.setFocusableInTouchMode(true);
>             convertView.setFocusable(true);
>             holder = new ViewItemHolder();
>             holder.timeStamp = (TextView)
> convertView.findViewById(R.id.textView1);
>             holder.firstLine = (TextView)
> convertView.findViewById(R.id.textView2);
>             convertView.setTag(holder);
>         } else {
>             holder = (ViewItemHolder) convertView.getTag();
>         }
>         holder.timeStamp.setText(itemObj.getTitleItem(position));
>         holder.firstLine.setText(itemObj.getMessageItem(position));
>         holder.positionInList = position;
>         holder.listIndex = parent.getId();
>                 convertView.setOnClickListener(clickListener);
>         return convertView;
>         }
>
>         OnClickListener clickListener = new OnClickListener() {
>                 @Override
>                 public void onClick(View v) {
>                         // TODO Auto-generated method stub
>                         ViewItemHolder vh = (ViewItemHolder) v.getTag();
>                         Log.v(TAG, "[" + vh.listIndex + "][" + 
> vh.positionInList + "] " +
> (String) vh.timeStamp.getText() + ", " + (String)
> vh.firstLine.getText());
>                 }
>         };
>
> }
>
> Thanks

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