I want to show some list of TextView and EditView in my Widget.
I used the following code to generate list of TextView and EditView
public LinearLayout getMainBodyLayout(List<Item> data) {
LinearLayout mainLL = new LinearLayout(context);
mainLL.setOrientation(LinearLayout.VERTICAL);
for (int i = 0; i < data.size(); i++) {
Item ritem = data.get(i);
LinearLayout item = new LinearLayout(context);
TextView name = new TextView(context);
EditText nos = new EditText(context);
name.setText(ritem.getName());
nos.setText(ritem.getNo());
item.addView(name);
item.addView(nos);
mainLL.addView(item);
}
return mainLL;
}
public void updateWidget(LinearLayout ll) {
AppWidgetManager manager = AppWidgetManager.getInstance(context);
ComponentName thisWidget = new ComponentName(context, MainWidget.class);
RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
R.layout.widget_my);
remoteViews.setTextViewText(R.id.title, title);
remoteViews.setTextViewText(R.id.widget_error, errorMsg);
// I ve to add ll to this remoteViews
manager.updateAppWidget(thisWidget, remoteViews);
}
I have to add the returned LinearLayout to my widget Linearlayout. Please provide me the best way to do this.