Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom dialog box
    primarykey
    data
    text
    <p>I want to create a custom dialog box with textfields inside them. However, I am having trouble viewing the custom dialog box I made when I click the button. Anyone know why this would be? </p> <pre><code>public class MainActivity extends Activity {private Button mButton1; private Button mButton2; private Button mButton3; private Button mButton4; private Button mButton5; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mButton1 = (Button) findViewById(R.id.button1); mButton2 = (Button) findViewById(R.id.button2); mButton3 = (Button) findViewById(R.id.button3); mButton4 = (Button) findViewById(R.id.button4); mButton5 = (Button) findViewById(R.id.button5); mButton1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { show(); } }); mButton2.setOnClickListener(new View.OnClickListener() { //This is where my button is for the dialog box @Override public void onClick(View v) { // TODO Auto-generated method stub onCreateDialog(null); } }); } public void show() { AlertDialog.Builder builder=new AlertDialog.Builder(this); builder.setTitle("CHECK IT out"); builder.setMessage("Test"); builder.setNegativeButton("Cancel", null); builder.setPositiveButton("cool", null); AlertDialog alert = builder.create(); alert.show(); } //This is where I'm having trouble public class FireTheDialogFragment extends DialogFragment { public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); // Get the layout inflater LayoutInflater inflater = MainActivity.this.getLayoutInflater(); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout builder.setView(inflater.inflate(R.layout.dialog_signin, null)) // Add action buttons .setPositiveButton(R.string.signin, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); return builder.create(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } </code></pre> <p>Here's the xml file </p> <pre><code>&lt;EditText android:id="@+id/username" android:inputType="textEmailAddress" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="16dp" android:layout_marginLeft="4dp" android:layout_marginRight="4dp" android:layout_marginBottom="4dp" android:hint="@string/username" /&gt; &lt;EditText android:id="@+id/password" android:inputType="textPassword" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="4dp" android:layout_marginLeft="4dp" android:layout_marginRight="4dp" android:layout_marginBottom="16dp" android:fontFamily="sans-serif" android:hint="@string/password"/&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload