0

Haven't found a successful way to remove a view from a StackView Widget. I'm working off of the basic StackView example that comes with the SDK.

Here's what I'm trying to do in the getViewAt(int position) function to a certain view that I do not want to display in the widget in a certain situation:

rv.removeAllViews(R.id.widget_item);
mWidgetItems.remove(position);
mCount = mCount -1;
AppWidgetManager awm = AppWidgetManager.getInstance(mContext);   
awm.notifyAppWidgetViewDataChanged(awm.getAppWidgetIds(new ComponentName(mContext, WidgetProvider.class)), R.id.widget_item);

I also tried

rv.setViewVisibility(R.id.widget_item, View.GONE); 

instead of

rv.removeAllViews(R.id.image_frame);

Both of these will cause the view to be blank, but the view is still there. I can tell because when I flip through the StackView I see an empty position.

Randy
  • 955
  • 9
  • 16

2 Answers2

0

if you want to set the Visibility you must code like:

mView.sezVisibility(View.Gone);

if you want to remove then:

rv.removeView(mButton); //For examble remove a button
Mert
  • 1,333
  • 1
  • 12
  • 15
  • Thank you for your feedback. This widget uses RemoteViews and these two functions you mentioned do not work with RemoteViews. – Randy Feb 04 '14 at 08:16
  • 1
    oww SRY, i thought the rv are a laout or something like that sry :D – Mert Feb 04 '14 at 09:21
0

The StackView uses an Adapter to know how many elements to show. If you want to add or remove an element you need to modify the Adapter, no change the View directly.

  • I'm not sure how to modify a remoteAdapter. This link explains how I would set the text for a TextView: http://stackoverflow.com/questions/4528824/just-update-a-widget-remoteviews-instead-of-completly-creating-a-new-one But, I want to remove an entire view from the widget, not just modify the text. – Randy Feb 04 '14 at 09:14