Example usage for android.widget RemoteViews setScrollPosition

List of usage examples for android.widget RemoteViews setScrollPosition

Introduction

In this page you can find the example usage for android.widget RemoteViews setScrollPosition.

Prototype

public void setScrollPosition(int viewId, int position) 

Source Link

Document

Equivalent to calling ListView#smoothScrollToPosition(int) .

Usage

From source file:au.com.wallaceit.reddinator.Rservice.java

private void hideWidgetLoader(boolean goToTopOfList, boolean showError) {
    AppWidgetManager mgr = AppWidgetManager.getInstance(mContext);
    // get theme layout id
    int layout = 1;
    switch (Integer.valueOf(mSharedPreferences.getString("widgetthemepref", "1"))) {
    case 1://  w w  w. j a  v  a  2s .c o m
        layout = R.layout.widgetmain;
        break;
    case 2:
        layout = R.layout.widgetdark;
        break;
    case 3:
        layout = R.layout.widgetholo;
        break;
    case 4:
        layout = R.layout.widgetdarkholo;
        break;
    case 5:
        layout = R.layout.widgettrans;
        break;
    }
    RemoteViews views = new RemoteViews(mContext.getPackageName(), layout);
    views.setViewVisibility(R.id.srloader, View.INVISIBLE);
    // go to the top of the list view
    if (goToTopOfList) {
        views.setScrollPosition(R.id.listview, 0);
    }
    if (showError) {
        views.setViewVisibility(R.id.erroricon, View.VISIBLE);
    }
    mgr.partiallyUpdateAppWidget(appWidgetId, views);
}