0

我有要求将图像列表加载到RemoteView中。为此,我使用ViewFlipper来显示用户何时单击下一个和上一个按钮。但是我面对ViewFlipper的问题是我无法动态地添加图像,而如果我在ViewFlipper本地加载绘图的图像,则会获得一次输出。请帮忙。我无法通过RemoteViews找到解决方案。我张贴我的代码,供您参考如下:如何将图像动态添加到RemoteView下的ViewFlipper中

@Override 
public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     RemoteViews expandedView = new RemoteViews(this.getPackageName(), R.layout.notification_viewflipper); 
     expandedView.setOnClickPendingIntent(R.id.img_left,getPendingSelfIntent(MainActivity.this, IMAGE_LEFT)); 
     expandedView.setOnClickPendingIntent(R.id.img_right,getPendingSelfIntent(MainActivity.this, IMAGE_RIGHT)); 

} 

protected PendingIntent getPendingSelfIntent(Context context, String action) { 
     Intent intent = new Intent(context,MyNotificationReceiver.class); 
     intent.setAction(action); 
     return PendingIntent.getBroadcast(context, 0, intent, 0); 
    } 

任何种类的技巧和提示的将是对我很大的帮助。提前致谢。

回答

0

只是偶然uppon这个问题,看到没有人回答...这是我的代码,以孩子的添加到viewFlipper一个远程视窗内:

RemoteViews carrouselItem = new RemoteViews(getPackageName(), R.layout.item_carrousel_notification); 
contentView1.setImageViewResource(R.id.product_image, R.drawable.ic_launcher); 
contentView1.setTextViewText(R.id.notification_title, "First Product"); 

RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.carrousel_notification); 
contentView.addView(R.id.notification_view_flipper, carrouselItem); 

替换R.drawable.ic_launcher与您要添加的图像到viewflipper(从url或其他来源得到它)。猜猜应该工作。我的问题是在扩展通知中使用viewflipper =/

相关问题