开发者

How to delete widget from activity?

It is possible to delete widget from main activity ? I am writing small notepad and when some note is deleted, I want to delete widget with this note.

EDIT:

When I do something like this:

Context context = getApplicationContext(); 
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); 
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
ComponentName thisWidget = new ComponentName(context, Widget.class);
remoteViews.removeAllViews(R.id.w开发者_如何学JAVAidgetLayout); 
appWidgetManager.updateAppWidget(thisWidget, remoteViews);

Widget is not visible (because it do not have any view), but I still can click on it etc.

I want delete widget from home screen in some Activity.


ViewGroup has several removeView*(View) methods. Alternatively you can call setVisibility(View.GONE) to make the widget disappear from the screen without actually deleting it.

Barry

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜