Can I add a dynamic view to the main screen?

I am writing a home screen widget. Is it possible to add a view, for example. ImageView, in a home screen widget via RemoteViews? I want to dynamically create views for the home screen widget.

Thank.

            updateViews = new RemoteViews(context.getPackageName(), R.layout.widget_news);

            updateViews.setTextViewText(R.id.widget_title, mTitle);

            updateViews.setImageViewBitmap(R.id.widget_picture, 
                        BitmapFactory.decodeByteArray(image, 0, image.length));

My code is similar to above. But when I call updateViews.addView(aView), my IDE did not allow me to do this and give me a compilation error.

+3
source share
1 answer

Each time you use RemoteViews, you push the definition of your user interface to the application widget. Do you want more Views? Just use the appropriate layout at this point when creating the instance RemoteViews.

+1

Source: https://habr.com/ru/post/1735634/


All Articles