Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I know it's over a year old, but calling <code>requestFeature()</code> never solved my problem. In fact I don't call it at all.</p> <p>It was an issue with inflating the view I suppose. Despite all my searching, I never found a suitable solution until I played around with the different methods of inflating a view.</p> <p>AlertDialog.Builder is the easy solution but requires a lot of work if you use the <code>onPrepareDialog()</code> to update that view.</p> <p>Another alternative is to leverage AsyncTask for dialogs.</p> <p>A final solution that I used is below:</p> <pre><code>public class CustomDialog extends AlertDialog { private View content; public CustomDialog(Context context) { super(context); LayoutInflater li = LayoutInflater.from(context); content = li.inflate(R.layout.custom_view, null); setUpAdditionalStuff(); // do more view cleanup setView(content); } private void setUpAdditionalStuff() { // ... } // Call ((CustomDialog) dialog).prepare() in the onPrepareDialog() method public void prepare() { setTitle(R.string.custom_title); setIcon( getIcon() ); // ... } } </code></pre> <p><strong>* Some Additional notes:</strong></p> <ol> <li>Don't rely on hiding the title. There is often an empty space despite the title not being set.</li> <li>Don't try to build your own View with header footer and middle view. The header, as stated above, may not be entirely hidden despite requesting FEATURE_NO_TITLE.</li> <li>Don't heavily style your content view with color attributes or text size. Let the dialog handle that, other wise you risk putting black text on a dark blue dialog because the vendor inverted the colors.</li> </ol>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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