Hi
I have made an BaseAdapter that does not show the onclick effect on the rows when the items get selected (orange background).
Im wondering what is needed to make the OnClickedItem effect appear. I tried to set the OnItemClickListener on the list, but it did not help.
here is my code:
private class MyAdapter extends BaseAdapter{
private Bingo activity;
public MyAdapter(Bingo context){
this.activity = context;
items = new ArrayList<String>();
}
public void add(String item){
items.add(item);
notifyDataSetChanged();
}
public void clear(){
items.clear();
notifyDataSetChanged();
}
private ArrayList<String> items;
public int getCount() {
return items.size();
}
public Object getItem(int position) {
return items.get(position);
}
public long getItemId(int position) {
return position;
}
public boolean isEnabled(int position){
return true;
}
public View getView(int position, View convertView, ViewGroup parent) {
if(position == getCount() - 5 && getCount() < 100){
Log.d("dbg","Autoadding...");
activity.add();
}
View view = null;
if (convertView == null) {
Log.i("dbg","new:"+position);
view = View.inflate(activity, R.layout.item, null);
}
else {
Log.i("dbg","recycle:"+position);
view = convertView;
}
TextView text = (TextView)view.findViewById(R.id.text);
text.setText(items.get(position)+" -------> pos:"+position);
return view;
}
}
item.xml that is inflated...
LinearLayout
android:id="@+id/root"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_marginRight="10dp"
android:src="@drawable/icon"
LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFF"
android:singleLine="true"
Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OK"
android:layout_gravity="right"
android:gravity="center_horizontal"
android:inputType="textUri"
/LinearLayout
/LinearLayout