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

  • Home
  • SEARCH
  • 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 6006409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:32:06+00:00 2026-05-23T01:32:06+00:00

I am programmically creating a view at runtime and I want to this view

  • 0

I am programmically creating a view at runtime and I want to this view to be added to my linearlayout dynamically at runtime. Here is the code I got:

public class Widget extends AppWidgetProvider {

    @Override
    public void onUpdate(Context context, AppWidgetManager appWidgetManager,
            int[] appWidgetIds) {
        RemoteViews updateViews = new RemoteViews(context.getPackageName(),
                R.layout.main);

        DemoView dv = new DemoView(context);

            // Stuck here...How do I add my new dv View to my android widget

        appWidgetManager.updateAppWidget(appWidgetIds, updateViews);
        super.onUpdate(context, appWidgetManager, appWidgetIds);
    }


     private class DemoView extends View {
        public DemoView(Context context) {
            super(context);


        }

        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);

            Paint LedColor = new Paint();
            Paint BlankColor = new Paint();
            Path p,p1;
            Matrix m = new Matrix();

            LedColor.setStyle(Paint.Style.FILL);
            LedColor.setColor(0xffffffff);

            BlankColor.setStyle(Paint.Style.FILL);
            BlankColor.setColor(0xff111111);

            DigitPaths dp = new DigitPaths();

            p = dp.GetDigitPath(-1);
            p1 = dp.GetDigitPath(5);

            p.offset(50, 50);
            p1.offset(50, 50);

            m.setScale(6.5f, 6.5f);
            p.transform(m);
            p1.transform(m);
            canvas.drawPath(p,BlankColor);
            canvas.drawPath(p1, LedColor);
        }
    }
}

Any help would be appreciated!

  • 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-23T01:32:07+00:00Added an answer on May 23, 2026 at 1:32 am

    It’s not possible to add a custom View to an app widget. See the “Creating the App Widget Layout” section of the App Widgets Dev Guide for what View types are allowed.

    Android 3.0 adds support for some views to display collections. See the “Using App Widgets with Collections” section for details.

    Otherwise, to dynamically add an allowed View to an App Widget, after inflating the RemoteViews and getting a reference to it, you can use its addView(View) method, or the addView(View) method on any of the View objects already in the RemoteViews.

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

Sidebar

Related Questions

I add header and footer view while creating my table. What I want to
I'm creating a custom View to be included in a class library. I need
I'm programmatically creating a folder using C# and need to set the default view
I'm programmatically creating an edmx file as part of our code generation process and
Im creating and adding a grid of buttons to my custom view keyboardView as
What is the easiest way of creating an UISwitch inside a grouped table view
I am creating a view controller programmatically which is a UITabBarDelegate and contains a
I'm current creating a UISegmentedControl programmatically in a view controller's viewDidLoad method and adding
I am creating a UIToolbar programmatically but the issue is the position of this
I'm creating a Windows Forms application that uses an embedded WebBrowser control to view

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.