當前位置: 首頁>>代碼示例>>Java>>正文


Java RemoteViews.setContentDescription方法代碼示例

本文整理匯總了Java中android.widget.RemoteViews.setContentDescription方法的典型用法代碼示例。如果您正苦於以下問題:Java RemoteViews.setContentDescription方法的具體用法?Java RemoteViews.setContentDescription怎麽用?Java RemoteViews.setContentDescription使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.RemoteViews的用法示例。


在下文中一共展示了RemoteViews.setContentDescription方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: generateMediaActionButton

import android.widget.RemoteViews; //導入方法依賴的package包/類
private static RemoteViews generateMediaActionButton(Context context, Action action) {
    boolean tombstone = action.getActionIntent() == null;
    RemoteViews button = new RemoteViews(context.getPackageName(), R.layout.notification_media_action);
    button.setImageViewResource(R.id.action0, action.getIcon());
    if (!tombstone) {
        button.setOnClickPendingIntent(R.id.action0, action.getActionIntent());
    }
    if (VERSION.SDK_INT >= 15) {
        button.setContentDescription(R.id.action0, action.getTitle());
    }
    return button;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:13,代碼來源:NotificationCompatImplBase.java

示例3: onHandleIntent

import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
protected void onHandleIntent(@Nullable Intent intent) {
    //Retrieve widget ids
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
    final int[] appWidgetIds = appWidgetManager.getAppWidgetIds(
            new ComponentName(this, PerformanceWidgetProvider.class));
    //Create a latch for synchronization
    final CountDownLatch latch = new CountDownLatch(1);

    context = getApplicationContext();

    //Get firebaseuid
    String firebaseUid = CacheUtils.getFirebaseUserId(context);

    //Get data from firebase
    FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
    statsDbRef = firebaseDatabase.getReference()
            .child("users").child(firebaseUid).child("stats");

    valueEventListener = new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            stats = dataSnapshot.getValue(Stats.class);
            latch.countDown();
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            latch.countDown();
        }
    };
    statsDbRef.addListenerForSingleValueEvent(valueEventListener);

    try {

        //wait for firebase to download data
        latch.await();

        //check if download is successful
        if (stats != null) {
            final int todaysTotalSeconds = stats.getTodaysTotalSeconds();
            final int dailyAverage = stats.getDailyAverageSeconds();

            float progress;
            if (todaysTotalSeconds < dailyAverage) {
                progress = (todaysTotalSeconds / (float) dailyAverage) * 100f;
            } else {
                progress = 100f;
            }
            progress = Math.round(progress * 100) / 100f;

            for (int appWidgetId : appWidgetIds) {
                RemoteViews views = new RemoteViews(getPackageName(), R.layout.performance_widget);

                views.setTextViewText(R.id.todays_activity,
                        getString(R.string.todays_total_log_time, FormatUtils.getFormattedTime(context, todaysTotalSeconds)));
                views.setTextViewText(R.id.daily_average_text,
                        getString(R.string.daily_average_format, FormatUtils.getFormattedTime(context, dailyAverage)));

                views.setProgressBar(R.id.performance_bar, 100, (int) progress, false);

                String progressCd = getString(R.string.progress_description, progress);
                views.setContentDescription(R.id.performance_bar, progressCd);

                // Create an Intent to launch NavigationDrawerActivity
                Intent launchIntent = new Intent(this, NavigationDrawerActivity.class);
                PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, launchIntent, 0);
                views.setOnClickPendingIntent(R.id.widget, pendingIntent);

                appWidgetManager.updateAppWidget(appWidgetId, views);
            }
        }

    } catch (InterruptedException e) {
        FirebaseCrash.report(e);
    }
}
 
開發者ID:Protino,項目名稱:CodeWatch,代碼行數:78,代碼來源:PerformanceWidgetIntentService.java

示例4: getViewAt

import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public RemoteViews getViewAt(int position) {
  Log.d(TAG, "getViewAt()");
  Book book = new Book();
  try {
    book = books.get(position);

    // Construct a remote views item based on the app widget item XML file,
    // and set the text based on the position.
    RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_item);

    // set text to the views
    rv.setTextViewText(R.id.widget_txt_book_title, book.getTitle());
    rv.setTextViewText(R.id.widget_txt_author_name, book.getAuthor().getName());

    // set content description
    rv.setContentDescription(R.id.widget_txt_book_title, book.getTitle());
    rv.setContentDescription(R.id.widget_txt_author_name, book.getAuthor().getName());

    // set clickable button
    // Setting a fill-intent, which will be used to fill in the pending intent template
    // that is set on the collection view in Bookito provicer.
    Bundle extras = new Bundle();
    extras.putString(BooksWidgetProvider.CLICKED_ITEM_BOOK_ID, String.valueOf(book.getId()));
    extras.putString(BooksWidgetProvider.CLICKED_ITEM_BOOK_TITLE, book.getTitle());
    Intent fillInIntent = new Intent();
    fillInIntent.putExtras(extras);

    // Setting the action, so the widget provider can identify the event of this view
    // being clicked.
    fillInIntent.setAction(BooksWidgetProvider.CLICKED_ITEM_ACTION);

    // Make it possible to distinguish the individual on-click
    // action of a given item
    rv.setOnClickFillInIntent(R.id.widget_btn_select, fillInIntent);

    return rv;

  } catch (IndexOutOfBoundsException e) {
    Log.e(TAG, "getViewAt: ", e);
  }

  return null;
}
 
開發者ID:paulnunezm,項目名稱:Boookito-Capstone-Project,代碼行數:45,代碼來源:BooksRemoteViewsFactory.java

示例5: setRemoteContentDescription

import android.widget.RemoteViews; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
private void setRemoteContentDescription(RemoteViews views, String description) {
    views.setContentDescription(R.id.widget_icon, description);
}
 
開發者ID:changja88,項目名稱:Udacity_Sunshine,代碼行數:5,代碼來源:TodayWidgetIntentService.java


注:本文中的android.widget.RemoteViews.setContentDescription方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。