I'm developing and android app, and i'm having serious problems with listview.
At first I had an onItemClickListener and it worked well, but now, i've included some new features to the layout and it doesn't work.
my code is :
lv = (ListView) findViewById(R.id.listChap);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Toast.makeText(CapituloList.this,"Pulsado",Toast.LENGTH_SHORT).show();
Capitulo chap = (Capitulo) mAdapter.getItem(i);
Intent mIntent = new Intent(CapituloList.this, MangaView.class);
mIntent.putExtra("capitulo", chap);
startActivity(mIntent);
}
});
And in Capitulo Adapter I have:
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.list_manga_item_view,null);
TextView tv = (TextView) view.findViewById(R.id.nombre_manga);
ImageButton ib = (ImageButton) view.findViewById(R.id.checked_icon);
ImageButton ib2 = (ImageButton) view.findViewById(R.id.unchecked_icon);
tv.setText(mItems.get(i).getCapitulo());
return view;
}
Obviusly i want to diferientiate between touches on ib, ib2 and the rest of the Layout The visible result is: click on the URL, i have no reputation to post images https://i.stack.imgur.com/EU3o5.png
Thanks in advance
EDIT: SOLVED
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.list_manga_item_view,null);
TextView tv = (TextView) view.findViewById(R.id.nombre_manga);
final Capitulo chap = (Capitulo) this.getItem(i);
ImageButton ib = (ImageButton) view.findViewById(R.id.imageButton);
ib.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(mContext,"Button1 pressed",Toast.LENGTH_LONG).show();
}
});
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent mIntent = new Intent(mContext, MangaView.class);
mIntent.putExtra("capitulo", chap);
mContext.startActivity(mIntent);
}
});
ImageButton ib2 = (ImageButton) view.findViewById(R.id.imageButton2);
ib2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(mContext,"Button2 pressed",Toast.LENGTH_LONG).show();
}
});
tv.setText(mItems.get(i).getCapitulo());
return view;
}