Shruti Shruti - 4 years ago 155
Android Question

setTextviewText() method of RemoteView class not setting any text

I am using GridView in app widget.I want to show images and a text below each image in the widget.Images(app icons) are getting displayed; but the text is not getting displayed.I am using setTextViewText() to set the text.

getViewAt() method of class:

public RemoteViews getViewAt(int position) {

RemoteViews row = new RemoteViews(mContext.getPackageName(), R.layout.widget_list_row);

ApplicationInfo data = null;
Bundle extras = new Bundle();
Intent fillInIntent = new Intent(mContext, NotificationReceiverIntent.class);
PendingIntent pendingLaunchIntent;
try {
packageName = appsPackageNameList.get(position).split(";;");
data = packageManager
.getApplicationInfo(packageName[0], 0);

if (null != data) {
Bitmap icon = CommonCode.getBitmapFromIcon(data.loadIcon(packageManager));
row.setImageViewBitmap(, icon);
Log.e("count", packageName[1]);
row.setTextViewText(, packageName[1]); //setting text

} catch (final PackageManager.NameNotFoundException e) {
return (row);

I am printing the text(array value)which is giving me proper values.
So what should I do to set the text in my widget?

Answer Source

I got my answer after digging into my code. The default color of TextView is white in the widget so I simply change my Text color to black from xml and it worked!!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download