java - Multiple ImageButtons in a single Android Activity -
i'm creating app needs multiple image buttons. when have more 1 images loaded app stops responding. dont error messages stops working? code i'm using:
public class itemmatch extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_item_match); imagebutton ariel = (imagebutton)findviewbyid(r.id.imagebuttonariel); imagebutton belle = (imagebutton)findviewbyid(r.id.imagebuttonbelle); //*****setting images buttons***** ariel.setimageresource(r.drawable.ariel); belle.setimageresource(r.drawable.belle); //******listeners image buttons***** ariel.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { toast atest = toast.maketext(getapplicationcontext(), "ariel!", toast.length_short); atest.show(); } }); belle.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { toast atest = toast.maketext(getapplicationcontext(), "belle!", toast.length_short); atest.show(); } }); //*****countdown timer***** final textview text1=(textview)findviewbyid(r.id.textview2); final textview score =(textview)findviewbyid(r.id.textview3); new countdowntimer(30000,1000){ @override public void ontick(long millisuntilfinished) { text1.settext("time left: " + millisuntilfinished /1000 + "s"); score.settext("score: "); } @override public void onfinish() { text1.settext("game over!"); } }.start(); }
this xml it:
<textview android:layout_width="100dp" android:layout_height="100dp" android:text="" android:id="@+id/textview2" android:clickable="false" android:textalignment="center" android:layout_alignparenttop="true" android:layout_alignparentleft="true" android:layout_alignparentstart="true" /> <textview android:layout_width="75dp" android:layout_height="75dp" android:text="" android:id="@+id/textview3" android:layout_aligntop="@+id/textview2" android:layout_alignparentright="true" android:layout_alignparentend="true" /> <imagebutton android:layout_width="90dp" android:layout_height="90dp" android:scaletype="fitxy" android:id="@+id/imagebuttonariel" android:layout_above="@+id/imagebuttonbelle" android:layout_alignright="@+id/textview2" android:layout_alignend="@+id/textview2" /> <imagebutton android:layout_width="90dp" android:layout_height="90dp" android:scaletype="fitxy" android:id="@+id/imagebuttonbelle" android:layout_alignparentbottom="true" android:layout_alignleft="@+id/imagebuttonariel" android:layout_alignstart="@+id/imagebuttonariel" /> <imageview android:layout_width="200dp" android:layout_height="250dp" android:scaletype="fitxy" android:src="@drawable/belle" android:id="@+id/imageview" android:layout_below="@+id/textview3" android:layout_centerhorizontal="true" />
Comments
Post a Comment