I want to add an button to the footer of listview, I'm using horizontal listview, The adapter class:
public ItemAdapter(Context context, int layout, Cursor c,String[] from, int[] to) {
super(context, layout, c, from, to,0);
this.layout = layout;
inflator= LayoutInflater.from(context);
}
I return the newView and bindView:
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View v = inflator.inflate(layout, parent, false);
TextView footer = (TextView)v.findViewById(R.id.bAdd);
return v;
}
#Override
public void bindView(View v, final Context context, Cursor c) {
final int id = c.getInt(c.getColumnIndex(ItemDb.ID));
final String name = c.getString(c.getColumnIndex(ItemDb.NAME));
}
and the activity class:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] from = new String[] { ItemDb.NAME, ItemDb.CONDITION, ItemDb.EMAIL};
int[] to = new int[] { R.id.etItemName, R.id.etItemCondition, R.id.etEmail };
itemAdapter = new ItemAdapter(this,R.layout.list_item, null, from, to);
this.setListAdapter(itemAdapter);
}
How can I add the button in listview footer?
Here is my xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/photo"
android:layout_width="85dp"
android:layout_height="85dp"
android:background="#drawable/photo_frame"
android:contentDescription="#string/imagedescription"
android:src="#drawable/ic_launcher" >
</ImageView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/condition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/name"
android:layout_marginLeft="10dp"
android:text="#string/condition"
android:textColor="#000"
android:textSize="14sp" />
<TextView
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/condition"
android:layout_marginLeft="10dp"
android:text="#string/email"
android:textColor="#000"
android:textSize="14sp" />
</RelativeLayout>
</LinearLayout>
Override getCount() of listview adapter to return data.size()+1 elements;
In getView() insert something like this:
if (position == data.size()){
return getFooterView();
}
In getFooterView() inflate proper layout with button.
Related
I have a listView with a button in each row. The problem is that I can click in my listView item and something happens, but my Button does not work, nothing happens. I've read some things about the solution, but none helped me.
Here's my list_row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:descendantFocusability="blocksDescendants"
>
<TextView
android:id="#+id/text_branche_cours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="English"
/>
<TextView
android:id="#+id/text_trait"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" - "
/>
<TextView
android:id="#+id/text_designation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reading"
android:layout_marginRight="150dp"
/>
<Button
android:id="#+id/bAjouterJalon"
android:layout_width="58dp"
android:layout_height="wrap_content"
android:background="#drawable/ic_action_add_jalon"
/>
And here's my customadapter class:
public class CustomAdapter extends SimpleCursorAdapter {
private Context mContext;
private Context appContext;
private int layout;
private Cursor cr;
private final LayoutInflater inflater;
public CustomAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
super(context, layout, c, from, to);
this.layout = layout;
this.mContext = context;
this.inflater = LayoutInflater.from(context);
this.cr = c;
}
#Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return inflater.inflate(layout, null);
}
#Override
public void bindView(View view, final Context context, final Cursor cursor) {
super.bindView(view, context, cursor);
final Button ajouter = (Button)view.findViewById(R.id.bAjouterJalon);
ajouter.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent retour = new Intent(mContext,OngletJalonsNotes.class);
mContext.startActivity(retour);
}
});
}
}
Thank you for the help.
#EDIT - my listview is unclickable now !!
you are making button focusable & focus on touch false so it will not detect your touch tab on your button, remove these two lines from your button tag in xml :
android:focusable="false"
android:focusableInTouchMode="false"
Example:
<Button
android:id="#+id/bAjouterJalon"
android:layout_width="58dp"
android:layout_height="wrap_content"
android:background="#drawable/ic_action_add_jalon"
/>
*****************New changes*******************
CustomAdapter.class:
public class CustomAdapter extends SimpleCursorAdapter {
private Context mContext;
private Context appContext;
private int layout;
private Cursor cr;
private final LayoutInflater inflater;
public CustomAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
super(context, layout, c, from, to);
this.layout = layout;
this.mContext = context;
this.inflater = LayoutInflater.from(context);
this.cr = c;
}
#Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return inflater.inflate(layout, null);
}
#Override
public void bindView(View view, final Context context, final Cursor cursor) {
super.bindView(view, context, cursor);
final Button ajouter = (Button)view.findViewById(R.id.bAjouterJalon);
final LinearLayout root_view = (LinearLayout)view.findViewById(R.id.item_root);
root_view.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// List item Click detected
}
});
ajouter.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent retour = new Intent(mContext,OngletJalonsNotes.class);
mContext.startActivity(retour);
}
});
}
}
List item xml:
<?xml version="1.0" encoding="utf-8"?><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/item_root"
android:descendantFocusability="blocksDescendants"
android:orientation="horizontal"
android:padding="16dp">
<TextView
android:id="#+id/text_branche_cours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="English" />
<TextView
android:id="#+id/text_trait"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"
android:text=" - " />
<TextView
android:id="#+id/text_designation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="150dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="Reading" />
<Button
android:id="#+id/bAjouterJalon"
android:layout_width="58dp"
android:layout_height="wrap_content"
android:background="#drawable/ic_action_add_jalon" />
</LinearLayout>
In your list_item xml put android:descendantFocusability="blocksDescendants"
in the LinearLayout .
I writing test application and I get a strange behavior of mainActivity.listItem, when I click on item yet another item can get visible,it can get dissapear by scrolling.I'm confused.Thanks!
MainActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
stethoInit();
mainActivity = DataBindingUtil.setContentView(this, R.layout.activity_main);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
cursor = getContentResolver().query(MyProvider.CONTENT_URI, null, null, null, null, null);
}
String[] from = new String[]{MyProvider.ID, MyProvider.TEXT};
int[] to = new int[]{R.id.t_id, R.id.t_text};
scAdapter = new SimpleCursorAdapter(this, R.layout.item, cursor, from, to, 0);
mainActivity.listItem.setAdapter(scAdapter);
scAdapter.notifyDataSetChanged();
mainActivity.listItem.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
FrameLayout v = (FrameLayout)view.findViewById(R.id.updateLayout);
Log.d("!!!",v.toString());
v.setVisibility(View.VISIBLE);
}
});
mainActivity.insert.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Fragment insertFragment = new Insert();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.container, insertFragment);
ft.addToBackStack(null);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.commit();
}
});
}
item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="#+id/updateLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<!-- TODO: Update blank fragment layout -->
<EditText
android:id="#+id/updateTextField"
android:layout_width="match_parent"
android:layout_height="50dp"
android:ems="10"
android:hint="#string/insertTextFieldHint"
android:focusable="false"
android:inputType="textPersonName" />
<Button
android:id="#+id/uodateRecButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="125dp"
android:layout_marginTop="65dp"
android:focusable="false"
android:text="#string/updateRecButton" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:id="#+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"/>
<TextView
android:id="#+id/t_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="#+id/t_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
UPDATE
I solved this problem by extending SimpleCursorAdapter ,maybe someone share with another solution?
private class MyAdapter extends SimpleCursorAdapter{
private int layout;
public MyAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
super(context, layout, c, from, to, flags);
this.layout = layout;
}
#Override
public void bindView(View view, Context context, Cursor cursor) {
String id = cursor.getString(colId);
String title = cursor.getString(colText);
TextView idView = (TextView)view.findViewById(R.id.t_id);
idView.setText(id);
TextView textView = (TextView)view.findViewById(R.id.t_text);
textView.setText(title);
}
#Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View view = getLayoutInflater().inflate(layout,parent,false);
return view;
}
#Override
public int getItemViewType(int position) {
return position;
}
#Override
public int getViewTypeCount() {
return getCount();
}
}
I am new to android . I have an application working with listview and i want to number each list view item.
Like,
1 list item
2 list item
3 list item
MainActivity.java
public class MainActivity extends AppCompatActivity {
private OrderDbManager orderDbManager;
private ListView listView;
private SimpleCursorAdapter adapter;
final String[] from = new String[] { OrderDbHelper.FOOD_NAME,
OrderDbHelper.QUANTITY, OrderDbHelper.PRICE };
final int[] to = new int[] {R.id.tvFoodName, R.id.tvItemQuantity, R.id.tvItemPrice };
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
orderDbManager = new OrderDbManager(this);
orderDbManager.open();
final Cursor cursor = orderDbManager.fetch();
listView = (ListView) findViewById(R.id.listView);
listView.setEmptyView(findViewById(R.id.empty));
adapter = new SimpleCursorAdapter(this, R.layout.list_item, cursor, from, to, 0);
adapter.notifyDataSetChanged();
LayoutInflater layoutInflater = getLayoutInflater();
listView.addHeaderView(layoutInflater.inflate(R.layout.cart_header,listView, false));
listView.setAdapter(adapter);
}
public class MyAdapter extends SimpleCursorAdapter {
public MyAdapter(Context context, int layout, Cursor c,
String[] from,int[] to) {
super(context, layout, c, from, to);
}
#Override
public int getCount() {
return 0;
}
#Override
public Object getItem(int arg0) {
return null;
}
#Override
public long getItemId(int arg0) {
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater layoutInflater =(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.list_item, null, true);
TextView txt= (TextView) convertView.findViewById(R.id.tvSlNo);
txt.setText(position + 1);
return convertView;
}
}
}
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</ListView>
list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:minHeight="50dp"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:id="#+id/tvSlNo"
android:layout_width="0dip"
android:layout_height="match_parent"
android:gravity="center"
android:textStyle="normal"
android:textColor="#android:color/black"
android:layout_weight="0.1" />
<TextView
android:id="#+id/tvFoodName"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:gravity="center"
android:textStyle="normal"
android:textColor="#android:color/black"
android:text=""/>
<TextView
android:id="#+id/tvItemQuantity"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.15"
android:textStyle="normal"
android:textColor="#android:color/black"
android:gravity="center"/>
<TextView
android:id="#+id/tvItemPrice"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:gravity="center"
android:textStyle="normal"
android:textColor="#android:color/black"
android:text=""/>
</LinearLayout>
i want to set numbering in tvSlNo.
please help
In your getView() method of your listViewAdapter simply use the position variable and set it on your TextView. You may need to add 1 to the position since it starts with 0. So use (position+1) and then set it to your TextView
Though this question may be too late but for other reference purposes.
Check where you have this code: txt.setText(position + 1);
you are close to your solution. You just have to typecast position + 1 to String since setText() only take String alone.
I'm trying to get data from sqlite to listview so i followed the example in the answer in this url
Make listview from SQLite database
the CustomCursorAdapter is going like that
public class CustomCursorAdapter extends SimpleCursorAdapter {
private int layout;
private LayoutInflater inflater;
private Context context;
public CustomCursorAdapter (Context context, int layout, Cursor c, String[] from, int[] to) {
super(context, layout, c, from, to);
this.layout = layout;
this.context = context;
inflater = LayoutInflater.from(context);
}
#Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View v = inflater.inflate(R.layout.topics, parent, false);
return v;
}
#Override
public void bindView(View v, Context context, Cursor c) {
//1 is the column where you're getting your data from
String name = c.getString(1);
/**
* Next set the name of the entry.
*/
TextView name_text = (TextView) v.findViewById(R.id.listLabel);
if (name_text != null) {
name_text.setText(name);
}
}
}
but onCreate i have this code
ListView listView = (ListView)findViewById(R.layout.topics);
connectToDB();
from = new String[] { "topicTitle" };
to = new int[] { R.id.listLabel };
CustomCursorAdapter adapter = new CustomCursorAdapter(this,
R.layout.topics, cursor, from, to);
listView.setAdapter(adapter);
with xml as follows
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp" >
<ImageView
android:id="#+id/listLogo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
>
</ImageView>
<TextView
android:id="#+id/listLabel"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="#+id/label"
android:textSize="15sp" >
</TextView>
</LinearLayout>
the problem is .. listView is Null!! .. which i don't know why!!
You are refering to your layout topics. You should have a listview defined in xml with a id.
In your activity onCreate() after setCOntentView(R.layout.topics), fins the id of listview and set adapter to your list.
In your xml say topics.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#0095FF">
<ListView android:id="#+id/list"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:id="#+id/lv">
</ListView>
// other ui elements
</LinearLayout>
Then in your activity onCreate()
setContentview(R.layout.topics);
ListView listView = (ListView)findViewById(R.id.lv);
connectToDB();
from = new String[] { "topicTitle" };
to = new int[] { R.id.listLabel };
CustomCursorAdapter adapter = new CustomCursorAdapter(this,
R.layout.topics, cursor, from, to);
listView.setAdapter(adapter);
From the discussion in chat
EDIT:
Define main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#0095FF">
<ListView android:id="#+id/list"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:focusableInTouchMode="false"
android:listSelector="#android:color/transparent"
android:layout_weight="2"
android:headerDividersEnabled="false"
android:footerDividersEnabled="false"
android:dividerHeight="8dp"
android:divider="#000000"
android:cacheColorHint="#000000"
android:drawSelectorOnTop="false">
</ListView>
</LinearLayout>
In your activivity
public class MainActivity extends Activity {
ListView lv;
CustomCursorAdapter cus;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lv = (ListView) findViewById(R.id.list);
cus= new CustomCursorAdapter(parameters);
lv.setAdapter(cus);
}
}
Define customCursor adapter inflate a custom layout. Set image for image view and text for textview.
Try to edit your xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:id="#+id/main"
>
<ImageView
android:id="#+id/listLogo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
>
</ImageView>
<TextView
android:id="#+id/listLabel"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="#+id/label"
android:textSize="15sp" >
</TextView>
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/topics"
></ListView>
</LinearLayout>
In Activity onCreate
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ListView listView = (ListView)findViewById(R.layout.topics);
connectToDB();
from = new String[] { "topicTitle" };
to = new int[] { R.id.listLabel };
CustomCursorAdapter adapter = new CustomCursorAdapter(this,
R.layout.topics, cursor, from, to);
listView.setAdapter(adapter);
}
I've a ListView that I populate with a SimpleCursorAdapter. For each item in my list i've, in this order: TextView > RatingBar > TextView > ImageView. I want to add a button on the ImageView but I dont know how to this...
Where I populate the ListView:
adapter = new SimpleCursorAdapter(this, R.layout.beerdrunk, cursor,
new String[] { "beers", "notes", "numbers" }, new int[] {
R.id.champName, R.id.champNote, R.id.champDrunk });
adapter.setViewBinder(binder);
list = (ListView) findViewById(R.id.listMyBeers);
list.setItemsCanFocus(true);
list.setOnItemClickListener(onClickBeer);
list.setAdapter(adapter);
The OnItemClickListener:
private OnItemClickListener onClickBeer = new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
System.out.println(""+ arg0);
System.out.println(""+ arg1);
System.out.println(""+arg2);
Intent newActivity = new Intent(MyBeers.this, DetailsBeer.class);
newActivity.putExtra("com.example.checkmybeer.DetailsBeer", ""
+ arg3);
startActivityForResult(newActivity, 0);
}
};
And the XML for beerdrunk:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/champName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="130"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:maxLines="3"
android:padding="5dp"
android:paddingRight="20dp"
android:singleLine="false"
android:text="#string/beerBook"
android:textColor="#color/black1"
android:textSize="20sp"
android:textStyle="bold" >
</TextView>
<View
android:layout_width="1.5dip"
android:layout_height="fill_parent" />
<RatingBar
android:id="#+id/champNote"
style="#style/beerRatingSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:isIndicator="true"
android:numStars="5"
android:layout_margin="1.5dp"
android:rating="5"
android:stepSize="0.10" >
</RatingBar>
<View
android:layout_width="1.5dip"
android:layout_height="fill_parent" />
<TextView
android:id="#+id/champDrunk"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="30"
android:gravity="right|center_vertical"
android:padding="5dp"
android:layout_marginLeft="5dp"
android:text="200"
android:textColor="#color/black1"
android:textSize="20sp"
android:textStyle="bold" />
<View
android:layout_width="1.5dip"
android:layout_height="fill_parent" />
<ImageView
android:id="#+id/champPlusone"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:layout_margin="5dp"
android:layout_weight="30"
android:gravity="right|center_vertical"
android:clickable="false"
android:src="#drawable/plus2" />
</LinearLayout>
I've tried something like:
if(arg2 instanceof ImageView){
//do some stuff
}
But it does not work... How can i do to know which view is clicked inside my "row" ?
If you want to click on an image, use an ImageButton instead of an ImageView.
You can then set the onClick attribute on the button that calls a method in your Activity.
Extend a SimpleCursorAdapter and in the bindView method add onClick listeners for each button. (Maybe make it call a method in your activity ... public void buttonClicked(int position, View v)... so you know which row and which view was clicked.
Here is an example implementation of CursorAdapter you could use.
class CustomCursorAdapter extends CursorAdapter{
LayoutInflater inflater;
public CustomCursorAdapter(Context context, Cursor c, int flags){
super(context,c,flags);
inflater = LayoutInflater.from(context);
}
#Override
public void bindView(View view, Context context, Cursor cursor){
int row_id = cursor.get('_id'); //Your row id (might need to replace)
ImageButton button = (ImageButton) view.findViewById(R.id.champPlusone);
button.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v){
//ADD STUFF HERE you know which row is clicked. and which button
}
});
}
#Override
public View newView(Context context, Cursor cursor, ViewGroup parent){
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(R.layout.beerdrunk, parent, false);
bindView(v,context,cursor);
return v;
}
}
;)