java - ListView doesn't work in my controller class Android -
i have problem app. have implemented mvc design pattern view , controller. controller have onclicklistener methods (4 buttons , listview). problem when activities begins buttons listeners responds listview stationnaire, can't click on , cant't scroll throught list.
show code. hope please.
all_products.xml
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/mylayout"> <listview android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="389dp" android:layout_alignparentleft="true" android:layout_alignparenttop="true"> </listview> <button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_alignparentleft="true" android:text="mapa" /> <button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_torightof="@+id/button1" android:text="lista" /> <button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_torightof="@+id/button2" android:text="buscador" /> <button android:id="@+id/button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_alignparentright="true" android:layout_torightof="@+id/button3" android:text="más" />
main activity
public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.all_products); final mymodel mymodel = new mymodel(); final myview myview = new myview(this); mycontroller mycontroller = new mycontroller(this, mymodel, myview); viewgroup container = (viewgroup) findviewbyid(r.id.mylayout); container.addview(myview); container.addview(mycontroller); bundle b=this.getintent().getextras(); string[] array=b.getstringarray("listaeventos"); //a continuación, generamos los distintos valores que ocuparán el linearlayout, concretamente //las categorías de los eventos. string[] values = new string[] { "actividades vacacionales", "aire libre y excursiones", "cine", "conferencias y otros", "congresos y jornadas", "cursos y talleres", "deporte", "escénicas", "exposiciones", "ferias", "fiestas y festivales", "música", "viajes", "otras" }; //llamamos al adapter personalizado para mostrar la vista. mylistcategoryarrayadapter adapter = new mylistcategoryarrayadapter(this, values, array); setlistadapter(adapter);
}
the controller
public class mycontroller extends relativelayout{ public mycontroller(activity activity, final mymodel mymodel, final myview myview) { super(activity, null); layoutinflater layoutinflater = (layoutinflater)activity.getsystemservice (context.layout_inflater_service); view view = layoutinflater.inflate(r.layout.all_products, this); final button button0 = (button) view.findviewbyid(r.id.button1); button0.setonclicklistener(new onclicklistener() { public void onclick(view v) { log.d("boton0", "boton0"); } }); final button button1 = (button) view.findviewbyid(r.id.button2); button1.setonclicklistener(new onclicklistener() { public void onclick(view v) { log.d("boton1", "boton1"); } }); final button button2 = (button) view.findviewbyid(r.id.button3); button2.setonclicklistener(new onclicklistener() { public void onclick(view v) { log.d("boton2", "boton2"); } }); final button button3 = (button) view.findviewbyid(r.id.button4); button3.setonclicklistener(new onclicklistener() { public void onclick(view v) { log.d("boton3", "boton3"); } }); listview list = (listview) view.findviewbyid(android.r.id.list); list.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> arg0, view view, int position, long id) { log.d("pulsando en lista", "pulsando en lista"); } });
Comments
Post a Comment