-5

Using android studio, How can I make 2 buttons name (submit) and (next page) but make the (next page) button unclickable. Then make it clickable after the (submit) button was clicked.

Abhinav Gupta
  • 2,225
  • 1
  • 14
  • 30

3 Answers3

4

Use this

Button submit, next;
submit= (Button) findViewById(R.id.submit);
next= (Button) findViewById(R.id.next);    
next.setEnabled(false);

submit.setOnClickListener(new View.OnClickListener() {
              @Override
                public void onClick(View v) {
                      next.setEnabled(true);

                }

        });
Syed
  • 166
  • 3
  • 15
1

You can use Clickable property as false and change it after clicking submit button.


Button submitButton, nextButton;
boolean b = false;

submitButton= findViewById(R.id.submitButton);
nextButton  =  findViewById(R.id.nextButton)

nextButton.setClickable(false);


submitButton.setOnClickListener(new View.OnClickListener() {
              @Override
                public void onClick(View v) {

                   nextButton.setClickable(true);

                }

        });
Rifat
  • 1,700
  • 3
  • 20
  • 51
0
  1. how can I make 2 buttons name (submit) and (next page) :- using xml create two buttons
<Button
            android:id="@+id/next_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Next"
            android:layout_gravity="center_horizontal"
            android:textAllCaps="false"/>
  1. But make the (nextpage) button unclickable :- In your MainActivity.java with
Button next =(Button) findViewById(R.id.next_button);
next.setEnabled(false);
  1. Then make it clickable after the (submit) button was clicked :-
btn_Submit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                next.setEnabled(true);
            }
        });

Hope this helps. No question is a bad question. Cheeers! Reply if any doubts.

sanjeev
  • 1,664
  • 19
  • 35