Android RemoteViews ListView Scroll

前端 未结 4 1928
花落未央
花落未央 2021-01-01 06:01

Im trying to scroll a ListView to a particular position in an AppWidget.

However it does not do anything, i also tried the setPosit

4条回答
  •  臣服心动
    2021-01-01 06:50

    Whit the information I have, I think that the widget doesn't invalidate itself so it doesn't so the changes on it. So I would suggest to refresh your widget. There are two ways to do that, the first one is:

    appWidgetManager.updateAppWidget(widgetId, remoteViews);
    

    and there is a second way only in case we don't have direct access to AppWidgetManager

    /**
     * Refresh the views on the widget
     * NOTE: Use only in case we dont have direct acces to AppWidgetManager
     */
    private void invalidateWidget() {
        ComponentName widget = new ComponentName(this, YourWidgetProvider.class);
        AppWidgetManager manager = AppWidgetManager.getInstance(this);
        manager.updateAppWidget(widget, mRv);
    }
    

    Like that the changes should be reflected in the widget. If this doesn't work I am gonna need more details to figure out the problem and edit this answer. Hope it helps.

提交回复
热议问题