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 7078901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:36:17+00:00 2026-05-28T06:36:17+00:00

Is there a way to get value from textView item inside widget ? I

  • 0

Is there a way to get value from textView item inside widget ? I have a 2 textViews in my widget layout and on my widget update I want to set new value to one of them and I don’t want to change value of the second one. For now when I set value like this

   remoteViews.setTextViewText(R.id.text1, newValue");
   widgetManager.updateAppWidget(thisWidget, remoteViews);

this is setting value of the second textView to default value defined in layout.
How to get it to not change the value of the second textView, or how to get value to the second textView to be able to adjust to the same ?

  • 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-05-28T06:36:18+00:00Added an answer on May 28, 2026 at 6:36 am

    It is my understanding that whenever onUpdate is called, it updates all of the widgets, so what I do is use SharedPreferences, so when I set the TextView initially I save the textView text to sharedprefs and then I get the preference when I update. And I do this all within a for loop.

    Here is my onUpdate:

    @Override
    public void onUpdate(Context context, AppWidgetManager awm, int[] appWidgetIds){
        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
        int appWidgetId;
        for (int i=0;i<appWidgetIds.length;i++){
                appWidgetId = appWidgetIds[i];
    
                String widgetLabel = pref.getString("label"+appWidgetId, "");
                // I previously saved "widgetLabel" when I created the widget in my 
                // ConfigurationActivity
                M.updateWidget(context, appWidgetId, widgetLabel);
                    // I put this in another class so it's more manageable.
            }
    
    
    
    }
    

    in my Class M:

    public static void updateWidget(Context context, int appWidgetId, String widgetLabel){
    
            SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
    
            RemoteViews updateViews;
            int layoutId = R.layout.layout;
            int viewId = R.id.layout;
    
            updateViews = new RemoteViews(context.getPackageName(),
                    layoutId);
            updateViews.setTextViewText(R.id.widgetlabel, widgetLabel);
            editor.putString("label"+appWidgetId, widgetLabel);
            editor.commit();
    
            Intent intent = new Intent(context, ClickAction.class); 
            PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
            updateViews.setOnClickPendingIntent(viewId, pendingIntent);
    
            AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, updateViews);
        }
    

    I hope that makes sense. Let me know if I need to elaborate on anything.

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

Sidebar

Related Questions

I want to get a value from 12 excel sheet. is there any way
Is there some way to get a value from the last inserted row? I
From the client, is there a way to get a true/false value from an
Is there a way to get one value from a tuple in Python using
In a Django template, is there a way to get a value from a
Is there a way to get a registry value from a server IP in
Is there some way to get a value from the last inserted row? I
I am wondering if there is a way to get css value from stylesheet
I want to get a value from the http_referer in the same/similar way you'd
Is there any way to get value of private static field from known class

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.