I’ve seen several posts about this, but found no answers to the issue that I’m experiencing. I’m dynamically filling a LinearLayout in a homescreen widget with RelativeLayout views, but only the first child view is displaying. Debugging shows that multiple views are being created and added, but they don’t appear. Here’s the code:
RemoteViews views = new RemoteViews(getPackageName(), R.layout.widget);
Cursor statuses_styles = getContentResolver().query(Uri.withAppendedPath(Statuses_styles.CONTENT_URI, widget), new String[]{...}, null, null, Statuses_styles.CREATED + " DESC LIMIT " + page + ",-1");
Log.d(TAG,"statuses count:"+statuses_styles.getCount());
if (statuses_styles.moveToFirst()) {
int count_status = 0;
views.removeAllViews(R.id.messages);
while (!statuses_styles.isAfterLast() && (count_status < 16)) {
RemoteViews itemView;
itemView = new RemoteViews(getPackageName(), R.layout.widget_item);
itemView.setTextViewText(R.id.message, statuses_styles.getString(1));
itemView.setFloat(R.id.message, "setTextSize", friend_textsize);
Log.d(TAG,"add view:"+statuses_styles.getString(1));
views.addView(R.id.messages, itemView);
count_status++;
statuses_styles.moveToNext();
}
}
statuses_styles.close();
mgr.updateAppWidget(appWidgetId, views);
The widget is simply a LinearLayout with the id of “messages”. It’s set to fill_parent for width and height and has orienation set to vertical.
The widget item is a relative layout containing some text and image views.
The widget is a 4×4.
Any ideas why none of the other views are appearing?
Thanks!
A child of the view being added had the attribute layout_alignParentBottom=”true”, which caused it to fill the whole parent, blocking any additional children. Removing the attribute allowed the other children to appear.