Adding android:focusable="false" does work with CheckBox (tested: just replace ImageButton with CheckBox in layout xml file).
On Feb 1, 11:12 am, qmwestview <qmwestv...@googlemail.com> wrote: > Hi Chander, > > thanks for your help. > > I have added > android:focusable="false" > to the layout xml file but the result appears to be the same. > > I thought this type oflistActivityworking with buttons etc is > supposed to be straightforward. But I failed to find a working example > so far. I am stucked here. > > On Jan 31, 8:22 am, Chander Pechetty <cspeche...@gmail.com> wrote: > > > make sure your list item does not contains focusable children (like > > buttons, imageviews) > > setting android:focusable="false" usually works for buttons and so > > on... > > > On Jan 30, 2:42 pm, qmwestview <qmwestv...@googlemail.com> wrote: > > > > Hi, > > > > I have a workingListActivityclass. Each of the list item consists of > > > an ImageView and a TextView. > > > > However, when I try to replace the ImageView withImageButton, The > > > list becomes unselectable. The onListItemClick or any other function > > > no longer get called when press a list item (Although the track ball > > > can still focus a list item, but nothing more can be done). > > > > I have searched the forum and also the internet and failed to find any > > > such working example, apart from one guy reporting a similar problem > > > but with no answer. > > > > The following is my code: > > > > 1. The list_item.xml: > > > > <?xml version="1.0" encoding="utf-8"?> > > > <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/ > > > android" > > > android:layout_width="fill_parent" > > > android:layout_height="?android:attr/listPreferredItemHeight"> > > > > <ImageButton > > > android:id="@+id/refresh" > > > > android:layout_width="wrap_content" > > > android:layout_height="fill_parent" > > > android:layout_alignParentTop="true" > > > android:layout_alignParentBottom="true" > > > android:src="@drawable/refresh" /> > > > <TextView > > > android:id="@+id/title" > > > android:layout_width="fill_parent" > > > android:layout_height="fill_parent" > > > android:layout_toRightOf="@id/refresh" > > > android:layout_alignParentBottom="true" > > > android:layout_alignParentRight="true" > > > android:singleLine="true"/> > > > </RelativeLayout> > > > > 2. the MainListActivityclass: > > > > import android.app.Dialog; > > > import android.app.ListActivity; > > > import android.content.Context; > > > import android.os.Bundle; > > > import android.util.Log; > > > import android.view.KeyEvent; > > > import android.view.LayoutInflater; > > > import android.view.MenuItem; > > > import android.view.View; > > > import android.view.ViewGroup; > > > import android.widget.BaseAdapter; > > > import android.widget.Button; > > > import android.widget.ImageButton; > > > import android.widget.ImageView; > > > import android.widget.ListView; > > > import android.widget.TextView; > > > > public class TestListActivity extendsListActivityimplements > > > Constants { > > > > @Override > > > public void onCreate(Bundle savedInstanceState) { > > > super.onCreate(savedInstanceState); > > > setListAdapter(new EfficientAdapter(this)); > > > } > > > > @Override > > > protected void onListItemClick(ListView l, View v, int index, long > > > id) { > > > Log.i("", "onListitemClick"); > > > } > > > > public boolean onContextItemSelected(MenuItem item) { > > > Log.i("", "onContextItemSelected"); > > > return false; > > > } > > > > private class EfficientAdapter extends BaseAdapter implements > > > Constants { > > > private LayoutInflater layoutInflater; > > > > Context ctx; > > > public EfficientAdapter(Context context) { > > > // Cache the LayoutInflate to avoid asking for a > > > new one each time. > > > layoutInflater = LayoutInflater.from(context); > > > ctx = context; > > > } > > > > @Override > > > public int getCount() { > > > Log.i("", "getCount"); > > > return SIZE; > > > } > > > > @Override > > > public Object getItem(int position) { > > > Log.i("", "getItem"); > > > return "TBD"; } > > > > @Override > > > public long getItemId(int positin) { > > > Log.i("", "getItemId"); > > > return positin; > > > } > > > > public void update(int position) { > > > notifyDataSetChanged(); // triggers the view data > > > to be refreshed! > > > } > > > > /** > > > * Make a view to hold each list item > > > */ > > > @Override > > > public View getView(int position, View convertView, > > > ViewGroup > > > parent) { > > > Log.i("", "getView"); > > > ViewHolder holder; > > > if (convertView == null) { > > > convertView = > > > this.layoutInflater.inflate(R.layout.list_item, > > > parent, false); > > > > holder = new ViewHolder(); > > > holder.title = (TextView) > > > convertView.findViewById(R.id.title); > > > convertView.setTag(holder); > > > } else { > > > holder = (ViewHolder) > > > convertView.getTag(); > > > } > > > > holder.title.setText(R.string.title); > > > parent.focusableViewAvailable(convertView); // > > > originally without > > > this. Added for testing, still not working! > > > return convertView; > > > } > > > > private class ViewHolder { > > > //ImageButtonimageButton; > > > TextView title; > > > } > > > } > > > > } > > > > Is there any way to makeListActivityworking withImageButtonor this > > > actually can not be achieved (iPhone can this)? > > > > Any help would be most appreciated. -- 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