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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:45:25+00:00 2026-06-16T03:45:25+00:00

Looked through every question, can’t get it working. I wanna set an AppWidgets layout

  • 0

Looked through every question, can’t get it working.

I wanna set an AppWidgets layout with the value of a string (So the layout can be switched to another one by just changing the string).

String NoteString = "R.layout.widget_blue".toString();

int resID = context.getResources().getIdentifier(NoteString, "layout", context.getPackageName());

RemoteViews views = new RemoteViews(context.getPackageName(), resID);

don’t know why it doesn’t work, widget just says: “problem loading widget”..

This works fine:

RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_blue);

Thanks

  • 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-16T03:45:26+00:00Added an answer on June 16, 2026 at 3:45 am

    In order to construct a resource ID from string components, you must pass the individual components into getIdentifier(), not the fully qualified ID as a single parameter:

    //Get the ID for R.layout.widget_blue
    int resID = context.getResources().getIdentifier("widget_blue", "layout", context.getPackageName());
    

    Then just change the first parameter name to get a different layout resource.

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

Sidebar

Related Questions

I've looked through tons of posts and cannot figure out why I can't get
I looked through Stackoverflow and found almost identical question here . It was asked
I have looked for an answer for this nearly every where that I can
This might be a dumb question but I can't get this super simple script
I've looked at this every way I can think... The problem is that I
I have looked through replacing colors in an image but cannot get it to
I realise this question has been asked 100 times, but i've looked through the
Sorry if this question has already been answered elsewhere. I looked through stack overflow
I looked through other questions and couldn't find what I needed. Best if I
I looked through other StackOverFlow questions, but I'm a little confused. I'm trying to

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.