LWUIT Form with multiple Components
I've added multiple components to my LWUIT Form one by one,but the problem is i am not able to display those added components one by one as like i appended in my code,i am able to display date and my image on a single row(side by side)some times title and date on a single row,I am getting the details from Rss File. How to display those components like i added in my code one by one, but not 2 components in a single row?
thanks....
Here my code:
[QUOTE]Label pubDate = new Label(detailNews.getPubDate().substring(0, 16));
Label title=new Label();
title.setText(detailNews.getTitle());
title.startTicker();
pubDate.getStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL));
Image geImage = detailNews.geImage();
Label icon=new Label(geImage);
form2.addComponent(title);
form2.addComponent(pubDate);
textarea.setText(detailNews.getDescription());
textarea.requestFocus();
form2.addComponent(icon);
form2.addComponent(textarea);
form2.show();[/QUOTE]
Re: LWUIT Form with multiple Components
Hi pavanragi,
U can add more than one component in a single row as:
1)Take a new LWUIT container with BoxLayout as x-axis and add the components to the container that u want to be in a single row.
2) Add the container to the LWUIT Form
Re: LWUIT Form with multiple Components
Hi harsha
I've modified my code like you said,Here is the Code:
[QUOTE] Container container = new Container(new BoxLayout(BoxLayout.X_AXIS));
container.addComponent(pubDate);
container.addComponent(icon);
textarea.setText(detailNews.getDescription());
container.addComponent(textarea);
form2.addComponent(container);
form2.show();[/QUOTE]
But ,i am getting the Exception:
[QUOTE]java.lang.IllegalArgumentException: Component is already contained in Container: Container[x=0 y=0 width=238 height=85, layout = BoxLayout, scrollableX = false, scrollableY = false, components = [Label, Label, TextArea]]
- com.sun.lwuit.Container.insertComponentAt(Container.java:370)
[/QUOTE]
[QUOTE=harsha921;904962]Hi pavanragi,
U can add more than one component in a single row as:
1)Take a new LWUIT container with BoxLayout as x-axis and add the components to the container that u want to be in a single row.
2) Add the container to the LWUIT Form[/QUOTE]
Re: LWUIT Form with multiple Components
Hi pavanragi,
Only add the components which u want them to be in a row. Check your code once thouroughly where you are adding the components.
Somewhere you are adding the same component twice (for form as well as for container) i guess.
Re: LWUIT Form with multiple Components
[QUOTE=pavanragi;904968]Hi harsha
I've modified my code like you said,Here is the Code:
But ,i am getting the Exception:[/QUOTE]
Check your entire code once again . Lwuit will not allow any component to be add twice to a container . Even form is derived from container
so if you are adding the component to a container make sure you dont add it to a form .
Re: LWUIT Form with multiple Components
Create a Form object and set the Boxlayout Y-axis like this:
form2 = new Form();
form2.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
and add all the components one by one to the form reference:
form2.addComponent(title);
form2.addComponent(pubDate);
form2.addComponent(icon);
form2.addComponent(textarea);
form2.show();