java - setOnItemClickListener in custom ListView not Work ActionBarSherlock -
i'm using actionbar sherlock , works fine.
this code works fine in 2.x not in 4.x
the click works in versions 2.x not working in 4.x versions i've tried many ways , can not make click function
what problem?
import java.util.arraylist; import android.app.activity; import android.os.bundle; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.adapterview; import android.widget.adapterview.onitemclicklistener; import android.widget.arrayadapter; import android.widget.listview; import android.widget.textview; import android.widget.toast; import com.actionbarsherlock.app.sherlocklistactivity; public class inicio extends sherlocklistactivity { private listview mlistview; private arraylist<capitulos> listado; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); mlistview = getlistview(); listado = new arraylist<capitulos>(); for(int = 0; < 20; i++){ listado.add(new capitulos("titulo " + i, "descripcion " + i)); } adaptadortitulares adaptador = new adaptadortitulares(inicio.this); setlistadapter(adaptador); mlistview.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> a, view v, int position, long id) { toast.maketext(inicio.this, "hazlo", 0).show(); } }); } class adaptadortitulares extends arrayadapter { activity context; @suppresswarnings("unchecked") adaptadortitulares(activity context) { super(context, r.layout.lista, listado); this.context = context; } public view getview(int position, view convertview, viewgroup parent) { layoutinflater inflater = context.getlayoutinflater(); view item = inflater.inflate(r.layout.lista, null); textview titulo = (textview)item.findviewbyid(r.id.titulo_art); titulo.settext(((capitulos)getitem(position)).gettitulo()); textview subtitulo = (textview)item.findviewbyid(r.id.desc_art); subtitulo.settext(((capitulos)getitem(position)).getdescrip()); return(item); } } }
try define inside arrayyadapter
class onclicklistener()
:
item.setonclicklistener(.....
Comments
Post a Comment