Fab repression



  • How am I supposed to do that when I'm repressed? FloatingActionButton Did you return the original record? Here's the code:

    final FloatingActionButton btnKzt = (FloatingActionButton)header_0.findViewById(R.id.btn_kzt);
                btnKzt.setImageDrawable(getResources().getDrawable(R.drawable.ic_kzt));
                btnKzt.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        btnKzt.setImageDrawable(getResources().getDrawable(R.drawable.ic_usd));
                    }
                });
    

    Starting the application inside fab There's a KZT footage, when it's pressed, the recording changes to USD. How do you get the CZT back on the second strike?



  • You'll have a field in the middle of the class. boolean isUSD = false
    Next, you'll change your code to:

    final FloatingActionButton btnKzt = (FloatingActionButton)header_0.findViewById(R.id.btn_kzt);
                btnKzt.setImageDrawable(getResources().getDrawable(R.drawable.ic_kzt));
                btnKzt.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        btnKzt.setImageDrawable(getResources().getDrawable(isUSD ? R.drawable.ic_kzt : R.drawable.ic_usd));
                        isUSD = !isUSD;
                    }
                });
    

    P.C.
    This tape isUSD ? R.drawable.ic_kzt : R.drawable.ic_usd It's called a thermal operator. It's similar to the record:

    if(isUSD) {
        btnKzt.setImageDrawable(getResources().getDrawable(R.drawable.ic_kzt);
    } else {
        btnKzt.setImageDrawable(getResources().getDrawable(R.drawable.ic_usd);
    }
    

    But it's a very short record.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2