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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:27:43+00:00 2026-05-29T09:27:43+00:00

I am trying to use native components in a LWUIT app on Android platform.

  • 0

I am trying to use native components in a LWUIT app on Android platform.

private Component createNativeTextEdit() {
    final Object[] result = new Object[1];

    AndroidImplementation.runOnAndroidUIThreadAndWait(LWUITActivity.currentActivity, new Runnable() {
        @Override
        public void run() {
            EditText nativeView = new EditText(LWUITActivity.currentActivity);
            nativeView.setText("Type here..");

            result[0] = PeerComponent.create(nativeView);
        }
    });

    return (Component)result[0];   
}

I then place a component inside a form:

mMainForm = new Form();
mMainForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

mMainForm.addComponent(createNativeTextEdit());

mMainForm.show();

Then I get an “IllegalArgumentException: width and height must be > 0” when the system tries to draw the new form.

I traced the problem down to the call to AndroidImplementation.PeerWrapper.getBuffer() and the values returned by getWidth() and getHeight() are width=474 and height=0.

How is height supposed to be set? What am I missing?

Do you know of a working sample program that uses PeerComponent on Android? I searched the web but could only find some snippets where it is not clear where the code is called from, which thread it is executed on etc.

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-05-29T09:27:44+00:00Added an answer on May 29, 2026 at 9:27 am

    I figured out the issue.

    I am using LWUIT 1.5 thorsten_s port for Android.

    The issue is that LWUIT computes components preferred size before the native view is added so both width and height are set to 0.

    The way to fix it is to call View.measure() on the PeerWrapper at creation time to initialize it to preferred size.

    Inside AndroidImplementation.java at the end of the constructor for PeerWrapper class add the line:

    measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
    MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));

    This completely fixes the problem. I can now use components like AnalogClock, DatePicker, and native EditText in LWUIT forms.

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

Sidebar

Related Questions

I'm developing a native app for Android and I'm trying to use functions such
I'm trying to use new OpenCV feature on Android: native camera access. According to
I'm trying to use Titanium.Android.Calendar API to view the device calendar (the native one),
I am trying to use native windows API with Qt using mingw toolset. There
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on
I am trying use a Java Uploader in a ROR app (for its ease
Trying to use this code to connect the AD PrincipalContext context = new PrincipalContext(ContextType.Domain,
I'm trying to use Cake's native caching methodes to cache some data that I
I'm trying to use the native flex serialization/deserialization process to save/load state of a
java.util.zip has well-known problems with native memory usage, so i'm trying to use a

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.