Skip to main content

Posts

Showing posts with the label overlayDialog

Using DialogFragments in Android

MainActivity.java : public class MainActivity extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FragmentManager fm = getSupportFragmentManager(); dialogfragment testDialog = new dialogfragment(); testDialog.setRetainInstance(true); testDialog.show(fm, "fragment_name"); }} Dialogfragment.java : public class Dialogfragment extends DialogFragment { public void TestDialog() { // Empty constructor required for DialogFragment } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { View view = inflater.inflate(R.layout.dialog, container); return view; } } dialog.xml : <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/edit_name" ...

Custom AlertBox in Android

in main.xml file: < ?xml version="1.0" encoding="utf-8"?> < LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > < Button android:id="@+id/button1" android:layout_width="120dp" android:layout_height="wrap_content" android:text="Button" /> < /LinearLayout> in dialog.xml :(xml for custom dialog box) : < ?xml version="1.0" encoding="utf-8"?> < LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > < ImageView android:id="@+id/imageView1" android:layout_widt...

Disabling the Touch of an Activity

On a button click we are creating the same class as a dialog so that the touch is not received public class MainActivity extends Activity { Dialog overlayDialog; EditText edt; Button bt; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); edt=(EditText)findViewById(R.id.editText1); bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub 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(MainActi...