Code example for ImageButton

Methods: setEnabledsetOnClickListener

0
    final String libId = currentEntry.getSong().getId();
    final String title = currentEntry.getSong().getTitle();
    final ImageButton upButton = (ImageButton)view.findViewById(R.id.upvote_button);
    final ImageButton downButton = (ImageButton)view.findViewById(R.id.downvote_button);
 
    upButton.setOnClickListener(new View.OnClickListener(){
      public void onClick(View v){
        currentEntry.removeFromDownvoters(me);
        currentEntry.addToUpvoters(me);
        upVoteSong(libId);
        notifyDataSetChanged(); 
      } 
    }); 
 
    downButton.setOnClickListener(new View.OnClickListener(){
      public void onClick(View v){
        currentEntry.addToDownvoters(me);
        currentEntry.removeFromUpvoters(me);
        downVoteSong(libId);
        notifyDataSetChanged(); 
      } 
    }); 
 
    /* Reset buttons from previous view*/ 
    upButton.setEnabled(true);
    downButton.setEnabled(true);
    if(currentEntry.getUpvoters().contains(me)){
      upButton.setEnabled(false);
    } 
    else if(currentEntry.getDownvoters().contains(me)){
      downButton.setEnabled(false);
    } 
 
Stop searching for code, let great code find you!  Add Codota to your java IDE