0

I have a requirement to load a list of images into RemoteView's. For that purpose I am using ViewFlipper to show when the user clicks next and previous buttons. But the problem I am facing with ViewFlipper is that I couldn't able to add the images dynamically, whereas I am getting output once if I load the images from drawables locally inside the ViewFlipper. Kindly please help. I couldn't able to find the solution for this with RemoteViews. I am posting my code for your reference as follows:

 @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);
    }

Any sort of tips and hints will be much helpful for me. Thanks in advance.

Chandru
  • 5,954
  • 11
  • 45
  • 85

1 Answers1

0

Just stumbled uppon this question and seeing nobody has answered... This is my code to add childs to viewFlipper inside a remoteview:

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);

Replace R.drawable.ic_launcher with the image you want to add to the viewflipper (get it from url or from other sources). Guess that should work. My problem is using the viewflipper in the expanded notification =/

Dieguinho
  • 758
  • 2
  • 14
  • 31