Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple views not showing up in custom alert dialog
    primarykey
    data
    text
    <p>Edit: <strong>Lesson learned: set the orientation or stuff might not show up.</strong></p> <p>As per <a href="http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog" rel="nofollow">http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog</a> I'm trying to create a custom alert dialog. Specifically, I'm creating a dialog that contains multiple views (called HelpItemView) that each contain two textviews. I'm using this to create an alert dialog that contains help information in the form of title-content pairs. </p> <p>My problem is that only the first HelpItemView shows up, although I'm creating a bunch of them. Is there something in the alert dialog that is restricting this? I messed around with my code and didn't have any problem having all the HelpItemViews show up when they were attached to the main linear layout of my activity, it seems this problem only appears within the alert dialog.</p> <p>Code within my activity:</p> <pre><code>private void createHelp() { AlertDialog.Builder builder = new AlertDialog.Builder(this); Resources res = getResources(); LinearLayout help_root = (LinearLayout)getLayoutInflater().inflate(R.layout.help_frame, null); LinearLayout help = (LinearLayout) help_root.findViewById(R.id.helpGroup); help.addView(new HelpItemView(this, res.getString(R.string.help_main_welcome), res.getString(R.string.help_main_welcome_content))); help.addView(new HelpItemView(this, res.getString(R.string.add_id), res.getString(R.string.help_add_id_content))); help.addView(new HelpItemView(this, res.getString(R.string.view_ids), res.getString(R.string.help_view_ids_content))); help.addView(new HelpItemView(this, res.getString(R.string.view_map), res.getString(R.string.help_view_map_content))); help.addView(new HelpItemView(this, res.getString(R.string.browse_plants), res.getString(R.string.help_browse_plants_content))); help.addView(new HelpItemView(this, res.getString(R.string.btnQuickIdentification), res.getString(R.string.help_btnQuickIdentification_content))); help.addView(new HelpItemView(this, res.getString(R.string.btnOptions), res.getString(R.string.help_options_content))); builder.setView(help_root); AlertDialog alert = builder.create(); alert.show(); } </code></pre> <p>helpframe.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/helpGroup"&gt;&lt;/LinearLayout&gt; &lt;/ScrollView&gt; &lt;/LinearLayout&gt; </code></pre> <p>HelpItemView.java</p> <pre><code>public class HelpItemView extends RelativeLayout { private TextView m_vwItemTitle; private TextView m_vwItemText; public HelpItemView (Context context, String header, String content) { super(context); LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.help_item, this, true); m_vwItemTitle = (TextView) this.findViewById(R.id.helpItemHeader); m_vwItemText = (TextView) this.findViewById(R.id.helpItemText); setContent(header, content); } private void setContent(String header, String content) { m_vwItemTitle.setText(header); m_vwItemText.setText(content); } </code></pre> <p>}</p> <p>help_item.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="10dip"&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/helpItemHeader" android:textSize="20sp" android:textStyle="bold" android:layout_gravity="center" &gt;&lt;/TextView&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/helpItemText" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Maybe its something dumb and i'm just missing it, I don't know. Any thoughts/ help would be most appreciated. Oh, I'm developing on android 1.6 if that makes any difference. I'm open to converting to a listview if that would work better (or at all), but I'd still like to know what's wrong with the current code if anyone can figure it out.</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