KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to add text views arranged in a linear layout to my widget on runtime. I do following: LinearLayout l = new LinearLayout(context); for (int i = 0; i < 10; i++) { TextView t = new TextView(context); t.setText("Hello"); l.addView(t); } RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.main); RemoteViews view = new RemoteViews (context.getPackageName(), l.getId()); views.addView(R.layout.main, view); But when I add widget I get a Problem loading widget error. Seems like RemoteViews has a problem with receiving a constructed view id as a parameter. But I can't make a reference to XML resource, because they are created on runtime. What is the proper way to populate the RemoteViews with TextViews on runtime?
Tags (comma-separated)
Save Edits
Cancel