Skip to content Skip to sidebar Skip to footer

Converting RemoteView Into A View

I am trying to render a RemoteViews instance onto a Canvas, like I do with a regular View. I use RemoteViews.apply(context, null) and it returns a FrameLayout with all the views

Solution 1:

Not sure if the question is still actual. Nevertheless here is my experience with RemoveViews. It appears you cannot just call draw() on the returned view. You have to add this view to a parent container to make it a part of global view hierarchy. For instance, you have an Activity with a single FrameLayout in it. Your code will look like this.

FrameLayout parent = findViewById(R.id.container);
View view = RemoteViews.apply(getActivity(), parent);
parent.addView(view);

Now you should be able to see tests. If you set listeners, they will work properly too.


Post a Comment for "Converting RemoteView Into A View"