Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8864291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:12:23+00:00 2026-06-14T16:12:23+00:00

I have an app widget which displays some rss feeds.It contains a text view

  • 0

I have an app widget which displays some rss feeds.It contains a text view which will display news title and an image view to diplay image.In that widget I want to add two buttons which function as next and previous to navigate through news titles.I know how to do this in an activity but how can I implement onclick listener for these buttons in widget

Here is my xml=>

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
<ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:scaleType="centerCrop"
            android:src="@drawable/logo" />
<ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="100dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/imageView1"
            android:scaleType="centerCrop"
            android:src="@drawable/titlebg2" />
<ImageView
            android:id="@+id/imageView3"
            android:layout_width="wrap_content"
            android:layout_height="2dp"
            android:layout_below="@+id/imageView2"
            android:layout_centerHorizontal="true"
            android:scaleType="centerCrop"
            android:src="@drawable/foot" />
<ImageView
            android:id="@+id/imageView4"
            android:layout_width="90dp"
            android:layout_height="90dp"
            android:layout_alignParentLeft="true"
            android:layout_alignTop="@+id/imageView2"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="5dp"
            android:scaleType="centerCrop"
            android:src="@drawable/img" />
<Button
            android:id="@+id/next"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/imageView1"
            android:layout_marginRight="3dp"
            android:layout_marginTop="3dp"
            android:background="@drawable/up" />


        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/up"
            android:layout_alignBottom="@+id/up"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="25dp"
            android:layout_toRightOf="@+id/imageView4"
            android:text="TextView"
            android:textColor="#ffff" />
      <Button
            android:id="@+id/previous"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_alignBottom="@+id/imageView2"
            android:layout_alignLeft="@+id/up"
            android:layout_marginBottom="3dp"
            android:background="@drawable/down" />

    </RelativeLayout>

</LinearLayout>

Follwing is my onupdate function,
=>

 public void onUpdate( Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds )
        {

         parse();//Here Iam parsing the xml
         RemoteViews remoteViews;
             ComponentName watchWidget;


            remoteViews = new RemoteViews( context.getPackageName(), R.layout.widget_main );
            watchWidget = new ComponentName( context, madhyamambig.class );

            remoteViews.setTextViewText( R.id.title, Title[0]);


            Bitmap bitmap;
            try {
                bitmap = BitmapFactory.decodeStream((InputStream)new URL(image[0]).getContent());


                 remoteViews.setImageViewBitmap(R.id.imageView4, bitmap);
            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
                            appWidgetManager.updateAppWidget( watchWidget, remoteViews );

        }

On an activity, we can simply do this like,

     int i=0;
      next.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {


 Bitmap bitmap;
                try {
                    bitmap = BitmapFactory.decodeStream((InputStream)new      URL(image[i+1]).getContent());


                     remoteViews.setImageViewBitmap(R.id.imageView4, bitmap);
                } catch (MalformedURLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                                appWidgetManager.updateAppWidget( watchWidget, remoteViews );

            }
          }


        });

I want to implement the same in widget.Somebody please help me…Thanks in advance..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:12:24+00:00Added an answer on June 14, 2026 at 4:12 pm

    You can use RemoteViews.setOnClickPendingIntent method.

    Then launch a PendingIntent that will be caught by a service, a broadcast receiver or a service. The context targeted by this intent will be able to manipulate the source widget by using RemoteViews again.

    Click processing is a bit more complicated as everything that is a stake here is to manipulate UI elements in a remote process.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an android app (only Widget) which displays some images from a
I have a JavaScript widget which communicates with my Rails app by creating tags
What I have is an app that displays some documents. In the string resources
I have an app widget project, which relies that a corresponding app is installed.
I'd like to keep focus on the entry text widget, which will pass whatever's
I have a ModelForm in my Django app that uses a forms.ModelMultipleChoiceField, which displays
I have a widget which I am trying to use to display information from
I have got a few buttons which users can select and it will display
I have created an App Widget for Android 1.5. It uses a TextView to
I have 1 android app project and 1 widget project, they all work fine.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.