-2

There is a process that lasts 2 seconds, during the process I need to lock the entire screen and the buttons of the mobile phone. There is a code that disables only the cancellation process.

public void onClick(View view) {
    int pos = getAdapterPosition();
    dialog= new ProgressDialog(context);
    dialog.setMessage("Please wait ...");
    dialog.setCancelable(false);
    dialog.show();


    if(pos != RecyclerView.NO_POSITION){
        LanguageRecycler clickedDataItem = mData.get(pos);
        SharedPrefManager.getmInstance(context).setCity(clickedDataItem.getAlias());

        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {

                ((Activity)context).finish();

            }
        }, 2000);
    }
}
Fábio Nascimento
  • 2,644
  • 1
  • 21
  • 27
Muza Rasulov
  • 11
  • 1
  • 5

2 Answers2

-2

This will disable the button

    Button myButton = findViewById(R.id.button);
    myButton.setEnabled(false) 
-2

Try this one

@Override
   public boolean onKeyDown(int keyCode, KeyEvent event) {
     if (keyCode == KeyEvent.KEYCODE_BACK) {
        //do something or nothing here
      return true;
      }
     return super.onKeyDown(keyCode, event);    
   }