Note that there are some explanatory texts on larger screens.

plurals
  1. POwhat's wrong in this custom dialog
    primarykey
    data
    text
    <p>I am creating a custom dialog that will show the information of a food item: the xml layout for the dialog is</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout_root" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" &gt; &lt;TextView android:id="@+id/lblCal" android:layout_width="fill_parent" android:layout_height="wrap_content"&gt; &lt;/TextView&gt; &lt;TextView android:id="@+id/lblFat" android:layout_width="fill_parent" android:layout_height="wrap_content"&gt; &lt;/TextView&gt; &lt;TextView android:id="@+id/lblCarb" android:layout_width="fill_parent" android:layout_height="wrap_content"&gt; &lt;/TextView&gt; &lt;TableRow android:layout_width="fill_parent" android:layout_height="wrap_content"&gt; &lt;Button android:layout_width="wrap_content" android:text=" OK " android:id="@+id/btnOK" android:layout_height="wrap_content"&gt; &lt;/Button&gt; &lt;Button android:layout_width="wrap_content" android:text="Home" android:id="@+id/btnHome" android:layout_height="wrap_content"&gt; &lt;/Button&gt; &lt;/TableRow&gt; &lt;/LinearLayout&gt; </code></pre> <p>the onCreatDialog method is defined like this:</p> <pre><code>@Override protected Dialog onCreateDialog(int id) { Dialog d; switch (id) { case 0: d = new Dialog(this); d.setContentView(R.layout.result_dialog); d.setTitle(item); TextView lblEnergy = (TextView) d.findViewById(R.id.lblCal); lblEnergy.setText("Energy: "+ String.valueOf(cal)); TextView lblFat = (TextView) d.findViewById(R.id.lblCal); lblFat.setText("Fat: "+ String.valueOf(fat)); TextView lblCarbs = (TextView) d.findViewById(R.id.lblCal); lblCarbs.setText("Carbs: " + String.valueOf(carb)); Button ok = (Button) d.findViewById(R.id.btnOK); ok.setOnClickListener(i); Button home = (Button) d.findViewById(R.id.btnHome); home.setOnClickListener(i); break; default: d = null; } return d; } </code></pre> <p>but when I run the program the first two textview don't appear. </p> <p><strong>what is the problem?!!</strong></p> <p>what I should add to the ok button to close the dialog, because when I call DissmisDialog(0); when I click again on another item the dialog contents never changed</p>
    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.
 

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