当前位置: 首页>>代码示例>>Java>>正文


Java RemoteViews.setEmptyView方法代码示例

本文整理汇总了Java中android.widget.RemoteViews.setEmptyView方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteViews.setEmptyView方法的具体用法?Java RemoteViews.setEmptyView怎么用?Java RemoteViews.setEmptyView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.RemoteViews的用法示例。


在下文中一共展示了RemoteViews.setEmptyView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onUpdate

import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    for (int i = 0; i < appWidgetIds.length; ++i) {

        Intent intent = new Intent(context, StackWidgetService.class);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
        rv.setRemoteAdapter(appWidgetIds[i], R.id.stack_view, intent);

        rv.setEmptyView(R.id.stack_view, R.id.empty_view);

        Intent widgetIntent = new Intent(context, StackWidgetProvider.class);
        widgetIntent.setAction(StackWidgetProvider.WIDGET_ACTION);
        widgetIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        PendingIntent widgetPendingIntent = PendingIntent.getBroadcast(context, 0, widgetIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setPendingIntentTemplate(R.id.stack_view, widgetPendingIntent);

        appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
}
 
开发者ID:MuditSrivastava,项目名称:Canvas-Vision,代码行数:25,代码来源:StackWidgetProvider.java

示例2: updateWidgetListView

import android.widget.RemoteViews; //导入方法依赖的package包/类
private RemoteViews updateWidgetListView(Context context, int id) {
    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.launcher_list_widget);

    Intent intent = new Intent(context, AppWidgetService.class);
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id);
    intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));

    remoteViews.setRemoteAdapter(R.id.listViewWidget, intent);
    remoteViews.setEmptyView(R.id.listViewWidget, R.id.emptyView);

    Intent tempIntent = new Intent(context, PackageDetailsActivity.class);
    tempIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    remoteViews.setPendingIntentTemplate(R.id.listViewWidget,
            PendingIntent.getActivity(context, 0, tempIntent, PendingIntent.FLAG_CANCEL_CURRENT));

    return remoteViews;
}
 
开发者ID:TonnyL,项目名称:Espresso,代码行数:18,代码来源:AppWidgetProvider.java

示例3: updateAppWidget

import android.widget.RemoteViews; //导入方法依赖的package包/类
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                            int appWidgetId, Parcelable[] parcelables) {
    Log.v(TAG, "updateAppWidget parcelables = " + parcelables.length);
    // Construct the RemoteViews object
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.git_hub_journey_widget);

    Intent startActivityIntent = new Intent(context, GeneralActivity.class);
    PendingIntent startActivityPendingIntent = PendingIntent.getActivity(context, 0, startActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    views.setPendingIntentTemplate(R.id.widget_data_view, startActivityPendingIntent);

    Calendar calendar = Calendar.getInstance();
    DateFormat dateFormat = Utils.createDateFormatterWithTimeZone(context, context.getString(R.string.add_widget_date_format));
    views.setTextViewText(R.id.widget_date, dateFormat.format(calendar.getTime()));
    Intent intent = new Intent(context, StackWidgetService.class);
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    // When intents are compared, the extras are ignored, so we need to embed the extras
    // into the data so that the extras will not be ignored.
    intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
    Bundle bundle = new Bundle();
    bundle.putParcelableArray("parcelables", parcelables);
    intent.putExtra("bundle", bundle);
    views.setRemoteAdapter(R.id.widget_data_view, intent);
    views.setEmptyView(R.id.widget_data_view, R.id.empty_view);
    // Instruct the widget manager to update the widget
    appWidgetManager.updateAppWidget(appWidgetId, views);
}
 
开发者ID:OlgaKuklina,项目名称:GitJourney,代码行数:27,代码来源:GitHubJourneyWidgetProvider.java

示例4: updateAppWidgetLayout

import android.widget.RemoteViews; //导入方法依赖的package包/类
private static void updateAppWidgetLayout(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
    Filter filter = getFilter(context, appWidgetId);

    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.list_widget);

    Intent serviceIntent = new Intent(context, ListWidgetService.class);
    serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    serviceIntent.putExtra(AppIntent.EXTRA_QUERY_STRING, filter.getQuery());
    serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));

    // Tell ListView where to get the data from
    remoteViews.setRemoteAdapter(R.id.list_widget_list_view, serviceIntent);

    remoteViews.setEmptyView(R.id.list_widget_list_view, R.id.list_widget_empty_view);
    if (filter.getQuery() == null) {
        remoteViews.setTextViewText(R.id.list_widget_empty_view, context.getString(R.string.select_a_filter_long));
    } else {
        remoteViews.setTextViewText(R.id.list_widget_empty_view, context.getString(R.string.no_notes_found_after_search));
    }

    // Rows - open note
    final Intent onClickIntent = new Intent(context, ListWidgetProvider.class);
    onClickIntent.setAction(AppIntent.ACTION_CLICK_LIST_WIDGET);
    onClickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    onClickIntent.setData(Uri.parse(onClickIntent.toUri(Intent.URI_INTENT_SCHEME)));
    final PendingIntent onClickPendingIntent = PendingIntent.getBroadcast(context, 0,
            onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    remoteViews.setPendingIntentTemplate(R.id.list_widget_list_view, onClickPendingIntent);

    // Plus icon - new note
    remoteViews.setOnClickPendingIntent(R.id.list_widget_header_add, ShareActivity.createNewNoteIntent(context, filter));

    // Logo - open query
    Intent openIntent = Intent.makeRestartActivityTask(new ComponentName(context, MainActivity.class));
    openIntent.putExtra(AppIntent.EXTRA_QUERY_STRING, filter.getQuery());
    serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));
    remoteViews.setOnClickPendingIntent(R.id.list_widget_header_icon, PendingIntent.getActivity(context, 0, openIntent, PendingIntent.FLAG_UPDATE_CURRENT));

    Intent filterSelectIntent = new Intent(context, FilterSelectDialogActivity.class);
    filterSelectIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    filterSelectIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));
    remoteViews.setOnClickPendingIntent(R.id.list_widget_header_bar, PendingIntent.getActivity(context, 0, filterSelectIntent, PendingIntent.FLAG_UPDATE_CURRENT));

    remoteViews.setTextViewText(
            R.id.list_widget_header_filter,
            filter.getName());

    appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:50,代码来源:ListWidgetProvider.java

示例5: updateAppWidget

import android.widget.RemoteViews; //导入方法依赖的package包/类
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                            int appWidgetId) {

    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.monolith_widget);

    // Intent to launch MainActivity
    final Intent onItemClick = new Intent(context, MonolithWidget.class);
    onItemClick.setAction(ACTION_WIDGET_CLICK);
    if (intent != null) {
        onItemClick.setData(intent.getData());
        Log.e("Content not null", "updateAppWidget: " + intent.getData());
    }
    PendingIntent onClickPendingIntent = PendingIntent
            .getBroadcast(context, 0, onItemClick,
                    PendingIntent.FLAG_UPDATE_CURRENT);
    views.setPendingIntentTemplate(R.id.widget_list,
            onClickPendingIntent);
    views.setRemoteAdapter(R.id.widget_list,
            new Intent(context, WidgetService.class));
    views.setEmptyView(R.id.widget_list, R.id.widget_empty);

    // Instruct the widget manager to update the widget
    appWidgetManager.updateAppWidget(appWidgetId, views);
    appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.widget_list);
}
 
开发者ID:prshntpnwr,项目名称:Monolith,代码行数:26,代码来源:MonolithWidget.java

示例6: onUpdate

import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    // update each of the widgets with the remote adapter
    for (int i = 0; i < appWidgetIds.length; ++i) {

        // Here we setup the intent which points to the StackViewService which will
        // provide the views for this collection.
        Intent intent = new Intent(context, StackWidgetService.class);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
        // When intents are compared, the extras are ignored, so we need to embed the extras
        // into the data so that the extras will not be ignored.
        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
        rv.setRemoteAdapter(appWidgetIds[i], R.id.stack_view, intent);

        // The empty view is displayed when the collection has no items. It should be a sibling
        // of the collection view.
        rv.setEmptyView(R.id.stack_view, R.id.empty_view);

        // Here we setup the a pending intent template. Individuals items of a collection
        // cannot setup their own pending intents, instead, the collection as a whole can
        // setup a pending intent template, and the individual items can set a fillInIntent
        // to create unique before on an item to item basis.
        Intent toastIntent = new Intent(context, StackWidgetProvider.class);
        toastIntent.setAction(StackWidgetProvider.TOAST_ACTION);
        toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        PendingIntent toastPendingIntent = PendingIntent.getBroadcast(context, 0, toastIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setPendingIntentTemplate(R.id.stack_view, toastPendingIntent);

        appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:36,代码来源:StackWidgetProvider.java

示例7: onUpdate

import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

    for (int appWidgetId : appWidgetIds) {

        RemoteViews widgetViews = new RemoteViews(context.getPackageName(), R.layout.news_widget);
        Intent svcIntent = new Intent(context, NewsWidgetService.class);
        svcIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);

        svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));
        widgetViews.setRemoteAdapter(R.id.newsList, svcIntent);
        widgetViews.setEmptyView(R.id.newsList, R.id.emptyMessage);

        Intent clickAppIntent = new Intent(context, HomeActivity.class);
        Intent clickIntent = new Intent(context, DetailsActivity.class);
        PendingIntent appPI = PendingIntent.getActivity(context, 0, clickAppIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        PendingIntent clickPI = PendingIntent.getActivity(context, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        widgetViews.setOnClickPendingIntent(R.id.newsTitle, appPI);
        widgetViews.setPendingIntentTemplate(R.id.newsList, clickPI);

        appWidgetManager.updateAppWidget(appWidgetId, widgetViews);
    }

    super.onUpdate(context, appWidgetManager, appWidgetIds);
}
 
开发者ID:vikasdesale,项目名称:News24x7-news-from-every-part-of-the-world,代码行数:27,代码来源:NewsWidgetProvider.java

示例8: onUpdate

import android.widget.RemoteViews; //导入方法依赖的package包/类
@SuppressLint("PrivateResource")
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    for (int widgetId : appWidgetIds) {
        RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.buddy_widget_list);


        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            setRemoteAdapter(context, remoteViews);
        } else {
            setRemoteAdapterV11(context, remoteViews);
        }

        Intent clickIntentTemplate = new Intent(context, DetailActivity.class);

        PendingIntent pendingIntentTemplate = TaskStackBuilder.create(context)
                .addNextIntentWithParentStack(clickIntentTemplate)
                .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

        remoteViews.setPendingIntentTemplate(R.id.widget_list, pendingIntentTemplate);
        remoteViews.setEmptyView(R.id.widget_list, R.id.widget_empty);
        remoteViews.setContentDescription(R.id.widget_list, context.getString(R.string.widget_cd));
        appWidgetManager.updateAppWidget(widgetId, remoteViews);

        appWidgetManager.notifyAppWidgetViewDataChanged(widgetId, R.id.widget_list);

    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:30,代码来源:BuddyBookWidgetProvider.java

示例9: onUpdate

import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    super.onUpdate(context, appWidgetManager, appWidgetIds);
    // Perform this loop procedure for each App Widget that belongs to this provider
    for (int appWidgetId : appWidgetIds) {
        RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_detail);

        // Create an Intent to launch MainActivity for example when clicking on the title
        Intent intent = new Intent(context, FavoriteMovieActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
        rv.setOnClickPendingIntent(R.id.widget, pendingIntent);


        Log.d("ArticleWidgetProvider", "onUpdate called: ");
        // Set up the collection
        setRemoteAdapter(context, rv);


        Intent clickIntentTemplate = new Intent(context, DetailActivity.class);
        PendingIntent clickPendingIntentTemplate = TaskStackBuilder.create(context)
                .addNextIntentWithParentStack(clickIntentTemplate)
                .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setPendingIntentTemplate(R.id.widget_list_new, clickPendingIntentTemplate);
        rv.setEmptyView(R.id.widget_list_new, R.id.widget_empty);


        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.widget_list_new);
        // Tell the AppWidgetManager to perform an update on the current app widget
        appWidgetManager.updateAppWidget(appWidgetId, rv);

    }
}
 
开发者ID:ansh94,项目名称:DailyTech,代码行数:33,代码来源:ArticleWidgetProvider.java

示例10: onUpdate

import android.widget.RemoteViews; //导入方法依赖的package包/类
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    // Perform this loop procedure for each App Widget that belongs to this provider
    for (int appWidgetId : appWidgetIds) {
        RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_detail);

        // Create an Intent to launch MainActivity
        Intent intent = new Intent(context, MainActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
        views.setOnClickPendingIntent(R.id.widget, pendingIntent);

        // Set up the collection
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            setRemoteAdapter(context, views);
        } else {
            setRemoteAdapterV11(context, views);
        }
        boolean useDetailActivity = context.getResources()
                .getBoolean(R.bool.use_detail_activity);
        Intent clickIntentTemplate = useDetailActivity
                ? new Intent(context, DetailActivity.class)
                : new Intent(context, MainActivity.class);
        PendingIntent clickPendingIntentTemplate = TaskStackBuilder.create(context)
                .addNextIntentWithParentStack(clickIntentTemplate)
                .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
        views.setPendingIntentTemplate(R.id.widget_list, clickPendingIntentTemplate);
        views.setEmptyView(R.id.widget_list, R.id.widget_empty);

        // Tell the AppWidgetManager to perform an update on the current app widget
        appWidgetManager.updateAppWidget(appWidgetId, views);
    }
}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:32,代码来源:DetailWidgetProvider.java

示例11: onUpdate

import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    // update each of the app widgets with the remote adapter
    for (int i = 0; i < appWidgetIds.length; ++i) {

        // Set up the intent that starts the StackViewService, which will
        // provide the views for this collection.
        Intent intent = new Intent(context, LeaderboardWidgetService.class);

        // Add the app widget ID to the intent extras.
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));

        // Instantiate the RemoteViews object for the app widget layout.
        RemoteViews rv =
                new RemoteViews(context.getPackageName(), R.layout.widget_leaderboard);

        // Set up the RemoteViews object to use a RemoteViews adapter.
        // This adapter connects
        // to a RemoteViewsService  through the specified intent.
        // This is how you populate the data.
        rv.setRemoteAdapter(R.id.list_widget_leaderboard, intent);

        // The empty view is displayed when the collection has no items.
        // It should be in the same layout used to instantiate the RemoteViews
        // object above.
        rv.setEmptyView(R.id.list_widget_leaderboard, R.id.empty_view);

        appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
    }

    super.onUpdate(context, appWidgetManager, appWidgetIds);
}
 
开发者ID:jaysondc,项目名称:TripleTap,代码行数:34,代码来源:LeaderboardAppWidgetProvider.java

示例12: onUpdate

import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    super.onUpdate(context, appWidgetManager, appWidgetIds);
    boolean largeScreen = context.getResources().getBoolean(R.bool.large_layout);
    for (int appWidgetId : appWidgetIds) {
        RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget);

        // WidgetListService intent for populating collection views.
        Intent collectionIntent = new Intent(context, WidgetListService.class);
        rv.setRemoteAdapter(R.id.widget_list, collectionIntent);
        rv.setEmptyView(R.id.widget_list, R.id.widget_empty);

        // Intent for opening the main app from the widget title.
        Intent itemReaperIntent = new Intent(context, ItemsActivity.class);
        PendingIntent itemReaperPendingIntent = PendingIntent.getActivity(context, 0,
                itemReaperIntent, 0);
        rv.setOnClickPendingIntent(R.id.widget_title, itemReaperPendingIntent);

        // Intent for adding an item when clicking the add item button.
        Intent addItemIntent = largeScreen
                ? new Intent(context, ItemsActivity.class)
                : new Intent(context, EditItemActivity.class);
        addItemIntent.putExtra(EXTRA_EDIT_NEW_ITEM, true);
        addItemIntent.setAction(ACTION_EDIT_NEW_ITEM);
        PendingIntent addItemPendingIntent = TaskStackBuilder.create(context)
                .addNextIntentWithParentStack(addItemIntent)
                .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setOnClickPendingIntent(R.id.widget_add_item, addItemPendingIntent);

        // Collection for ItemDetailsActivity intent when opening individual list item.
        Intent clickIntentTemplate = largeScreen
                ? new Intent(context, ItemsActivity.class)
                : new Intent(context, ItemDetailsActivity.class);
        PendingIntent clickPendingIntentTemplate = TaskStackBuilder.create(context)
                .addNextIntentWithParentStack(clickIntentTemplate)
                .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setPendingIntentTemplate(R.id.widget_list, clickPendingIntentTemplate);
        appWidgetManager.updateAppWidget(appWidgetId, rv);
    }
}
 
开发者ID:mvescovo,项目名称:item-reaper,代码行数:41,代码来源:ItemWidgetProvider.java

示例13: onUpdate

import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    LOGD(TAG, "updating app widget");
    final boolean isAuthenticated = AccountUtils.hasActiveAccount(context);
    for (int appWidgetId : appWidgetIds) {
        // Specify the service to provide data for the collection widget.  Note that we need to
        // embed the appWidgetId via the data otherwise it will be ignored.
        final Intent intent = new Intent(context, ScheduleWidgetRemoteViewsService.class)
                .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        final RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget);
        rv.setRemoteAdapter(R.id.widget_schedule_list, intent);

        // Set the empty view to be displayed if the collection is empty.  It must be a sibling
        // view of the collection view.
        rv.setEmptyView(R.id.widget_schedule_list, android.R.id.empty);
        LOGD(TAG, "setting widget empty view");
        rv.setTextViewText(android.R.id.empty, context.getResources().getString(isAuthenticated
                ? R.string.empty_widget_text
                : R.string.empty_widget_text_signed_out));

        final PendingIntent refreshPendingIntent = PendingIntent.getBroadcast(context, 0,
                getRefreshBroadcastIntent(context, true), PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setOnClickPendingIntent(R.id.widget_refresh_button, refreshPendingIntent);

        final Intent onClickIntent = TaskStackBuilderProxyActivity.getTemplate(context);
        final PendingIntent onClickPendingIntent = PendingIntent.getActivity(context, 0,
                onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setPendingIntentTemplate(R.id.widget_schedule_list, onClickPendingIntent);

        final Intent openAppIntent = new Intent(context, MyScheduleActivity.class)
                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        final PendingIntent openAppPendingIntent = PendingIntent.getActivity(context, 0,
                openAppIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setOnClickPendingIntent(R.id.widget_logo, openAppPendingIntent);

        appWidgetManager.updateAppWidget(appWidgetId, rv);
    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:41,代码来源:ScheduleWidgetProvider.java

示例14: onUpdate

import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    final int N = appWidgetIds.length;

    // Perform this loop procedure for each App Widget that belongs to this provider
    for (int i = 0; i < N; i++) {
        int appWidgetId = appWidgetIds[i];

        // Get the layout for the App Widget and attach an on-click listener to the button
        RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);

        SharedPreferences sharedPreferences = context.getSharedPreferences(
                "" + appWidgetIds[i], Context.MODE_PRIVATE);
        String directory = sharedPreferences.getString(WIDGET_PATH, AppSettings.get().getNotebookDirectoryAsStr());
        Intent newDocumentIntent = new Intent(context, DocumentActivity.class)
                .putExtra(DocumentIO.EXTRA_PATH, new File(directory))
                .putExtra(DocumentIO.EXTRA_PATH_IS_FOLDER, true);

        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, newDocumentIntent, 0);
        views.setOnClickPendingIntent(R.id.widget_new_note, pendingIntent);

        Intent goToMain = new Intent(context, MainActivity.class);
        PendingIntent goToMainPendingIntent = PendingIntent.getActivity(context, 0, goToMain, 0);
        views.setOnClickPendingIntent(R.id.widget_header, goToMainPendingIntent);

        // ListView
        Intent notesListIntent = new Intent(context, FilesWidgetService.class);
        notesListIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
        notesListIntent.putExtra(DocumentIO.EXTRA_PATH, new File(directory));
        notesListIntent.putExtra(DocumentIO.EXTRA_PATH_IS_FOLDER, true);
        notesListIntent.setData(Uri.parse(notesListIntent.toUri(Intent.URI_INTENT_SCHEME)));

        views.setEmptyView(R.id.widget_list_container, R.id.widget_empty_hint);
        views.setRemoteAdapter(R.id.widget_notes_list, notesListIntent);

        Intent openNoteIntent = new Intent(context, DocumentActivity.class).setAction(Intent.ACTION_EDIT);
        PendingIntent openNotePendingIntent = PendingIntent.getActivity(context, 0,
                openNoteIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        views.setPendingIntentTemplate(R.id.widget_notes_list, openNotePendingIntent);

        // Tell the AppWidgetManager to perform an update on the current app widget
        appWidgetManager.updateAppWidget(appWidgetId, views);
    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
}
 
开发者ID:gsantner,项目名称:markor,代码行数:46,代码来源:MarkorWidgetProvider.java

示例15: onUpdate

import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

  // There may be multiple widgets active, so update all of them
  for (int appWidgetId : appWidgetIds) {

    // Set up the intent that starts the BooksWidgetServe, which will
    // provide the views for this collection.
    Intent intent = new Intent(context, BooksWidgetService.class);

    // Add the app widget ID to the intent extras.
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));

    // Instantiate the RemoteViews object for the app widget layout.
    // using the "RemoteViews adapter".
    RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_bookito);

    // Set up the RemoteViews object to use a RemoteViews adapter.
    // This adapter connects
    // to a RemoteViewsService  through the specified intent.
    // This is how you populate the data.
    rv.setRemoteAdapter(appWidgetId, R.id.widget_list, intent);


    // The empty view is displayed when the collection has no items.
    // It should be in the same layout used to instantiate the RemoteViews
    // object above.
    rv.setEmptyView(R.id.widget_list, R.id.widget_empty_view);

    // This section makes it possible for items to have individualized behavior.
    // It does this by setting up a pending intent template. Individuals items of a collection
    // cannot set up their own pending intents. Instead, the collection as a whole sets
    // up a pending intent template, and the individual items set a fillInIntent
    // to create unique behavior on an item-by-item basis.
    Intent clickIntent = new Intent(context, BooksWidgetProvider.class);
    // Set the action for the intent.
    // When the user touches a particular view, it will have the effect of
    // broadcasting TOAST_ACTION.
    clickIntent.setAction(BooksWidgetProvider.CLICKED_ITEM_ACTION);
    clickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
    PendingIntent toastPendingIntent = PendingIntent.getBroadcast(context, 0, clickIntent,
        PendingIntent.FLAG_UPDATE_CURRENT);
    rv.setPendingIntentTemplate(R.id.widget_list, toastPendingIntent);

    appWidgetManager.updateAppWidget(appWidgetId, rv);
    super.onUpdate(context, appWidgetManager, appWidgetIds);
    appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.widget_list);
  }


}
 
开发者ID:paulnunezm,项目名称:Boookito-Capstone-Project,代码行数:54,代码来源:BooksWidgetProvider.java


注:本文中的android.widget.RemoteViews.setEmptyView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。