[ACCEPTED]-RemoteView addView not working-android-remoteview
Accepted answer
The addView() method needs the id of the 4 view inside the layout you want to add this 3 new view to, not the layout itself.
Instead 2 of this:
views.addView(views.getLayoutId(), newView);
Try this:
views.addView(R.id.view_container, newView);
Assuming your layout looks 1 something like this:
file: layout/widget_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/view_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!-- New views will be added here at runtime -->
</LinearLayout>
</LinearLayout>
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.