• 10
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I have used a (+/-)button to increment or decrement a counter but I hv set an upper limit 2 so I want to disable the plus button of the ElegantNumberbutton after the counter reaches two,and I want the minus button to stay active.

public class MainActivity extends AppCompatActivity {

ElegantNumberButton numberbutton;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    numberbutton=(ElegantNumberButton)findViewById(R.id.numberButton);
  //  counter=(TextView)findViewById(R.id.counterTxt);



    numberbutton.setOnValueChangeListener(new ElegantNumberButton.OnValueChangeListener() {
        @Override
        public void onValueChange(ElegantNumberButton view, int oldValue, int newValue) {


            String count= numberbutton.getNumber();
            int temp=Integer.parseInt(count);
          if(temp>=2 ) {
              Toast.makeText(MainActivity.this, "NO more casual leave allowed", Toast.LENGTH_SHORT).show();
              numberbutton.setEnabled(false);



          }

        }
    });

}

If you mean this by ElegantNumberButton, I would say that it is not really a button. It is a RelativeLayout, so its setEnabled() do not change any of the children inside it. For disable the +/- buttons, try the following code:

for (int i = 0; i < numberbutton.getChildCount(); i++) {
   View child = numberbutton.getChildAt(i);
   child.setEnabled(false);
}
  • 1
Reply Report