This is a simple example showing how will you disable any input on your current application screen in android.
This is done by showing a transparent overlay dialog on the screen.
This is how it is done.
package pack.coderzheaven; import android.app.Activity; import android.app.Dialog; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast; public class DisableInputDemo extends Activity { Dialog overlayDialog; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button b = (Button)findViewById(R.id.Button01); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { disableAnyInput(); } }); } public void disableAnyInput(){ Toast.makeText(getApplicationContext(), "This will disable any input. Click the backbutton " + "to enable any input.", Toast.LENGTH_LONG).show(); overlayDialog = new Dialog(DisableInputDemo.this, android.R.style.Theme_Panel); overlayDialog.setCancelable(true); overlayDialog.show(); } }
The layout for the above java file- main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="How to disable any input on the screen? Coderzheaven Demo" /> <EditText android:text="" android:hint="Type anything" android:id="@+id/EditText01" android:layout_width="fill_parent" android:layout_height="wrap_content"> </EditText> <Button android:text="Click me to disable any input" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content"> </Button> </LinearLayout>