java - ImageButton Not clickable - AndroidStudio -


i have these declarations 4 imagebuttons on android app, far aren't clickable, class:

public class welcomescreen extends activity {  imagebutton completeprofile; imagebutton gotoportfolio; imagebutton findfriends; imagebutton readnews;  public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.welcome_activity);      completeprofile = (imagebutton) findviewbyid(r.id.completeprofile);     gotoportfolio = (imagebutton) findviewbyid(r.id.gotoportfolio);     findfriends = (imagebutton) findviewbyid(r.id.findfriends);     readnews = (imagebutton) findviewbyid(r.id.readnews);      completeprofile.setonclicklistener(new view.onclicklistener() {          @override         public void onclick(view arg0) {             intent = new intent(welcomescreen.this, profilemember.class);             startactivity(i);         }     });      gotoportfolio.setonclicklistener(new view.onclicklistener() {           @override          public void onclick(view arg0) {              intent = new intent(welcomescreen.this, portfoliomember.class);              startactivity(i);          }     });      findfriends.setonclicklistener(new view.onclicklistener() {           @override          public void onclick(view arg0) {              intent = new intent(welcomescreen.this, mainactivity.class);              startactivity(i);          }     });      readnews.setonclicklistener(new view.onclicklistener() {           @override          public void onclick(view arg0) {              intent = new intent(welcomescreen.this, webactivity.class);              startactivity(i);          }     });  }    } 

this layout:

<linearlayout         android:orientation="horizontal"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:layout_margintop="70dp"         android:layout_marginleft="105dp">          <imagebutton             android:layout_width="55dp"             android:layout_height="55dp"             android:id="@+id/completeprofile"             android:background="@drawable/completeprofile"             android:layout_marginleft="75dp"             android:clickable="true" />          <imagebutton             android:layout_width="55dp"             android:layout_height="55dp"             android:id="@+id/gotoportfolio"             android:background="@drawable/gotoportfolio"             android:layout_marginleft="65dp"             android:clickable="true" />          <imagebutton             android:layout_width="55dp"             android:layout_height="55dp"             android:id="@+id/findfriends"             android:background="@drawable/findfriends"             android:layout_marginleft="65dp"             android:clickable="true" />          <imagebutton             android:layout_width="55dp"             android:layout_height="55dp"             android:id="@+id/readnews"             android:background="@drawable/readnews"             android:layout_marginleft="65dp"             android:clickable="true" />      </linearlayout> 

they show perfectly, far cannot click of them, no stacktrace error, i'm quite puzzled =/

anybody can shed light on this?

thanks in advance!

you using png images background. should use android:src attribute instead of android:background touch feedback when button being clicked. if want change background must use xml drawable selector. see docs


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -