0

I wanted to create an illuminated button which closes my application, firstly(when it was basic not illuminated button) I tried to finish my app using finish(); but now it doesn't work, because when I places it somewhere in code it doesn't work, I don't know why. Maybe this function doesn't work for the all project ??

settings.setImageDrawable(getApplicationContext().getResources().getDrawable(R.drawable.set tings_button)); 
    settings.setOnClickListener(new OnClickListener() {

    public void onClick(View button) {
        if (button.isSelected()){
            button.setSelected(false);
        }
        else {
            button.setSelected(true);            

        }       

    }

finish();

     });   

I tried with systemexit and finish(); what I should do and where I should place one of the exit commands to finish my app ?

PS. Yes, I`ve read other similar topics but, there problem was much more complicated than mine.

1 Answers1

0

I think you need to put finish inside the onClick:

settings.setImageDrawable(getApplicationContext().getResources().getDrawable(R.drawable.set tings_button)); 
    settings.setOnClickListener(new OnClickListener() {

    public void onClick(View button) {
        if (button.isSelected()){
            button.setSelected(false);
        }
        else {
            button.setSelected(true);            
        }       
        finish();
    }
     });   
Uriel Frankel
  • 14,304
  • 8
  • 47
  • 69