本文整理汇总了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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}