Reputation: 1490
I have added a buttonField into a HorizontalFieldManager in Blackberry app. I added it after adding an EditField. Yet the buttonField doesnt appear. Below is my code
HorizontalFieldManager hfm = new HorizontlFieldManager();
BasicEditField edit = new BasicEditField("Label", "UP");
ButtonField button = new ButtonField("Search");
hfm.add(edit);
hfm.add(button);
add(hfm);
Upvotes: 1
Views: 192
Reputation: 28199
This answer won't solve your problem, but it is important to note that your code is absolutely fine, and there's nothing wrong with it.
HorizontalFieldManager
class is full of bugs introduced in OS 5.0 and as for today (latest version are 7.x) RIM has shown no intention whatsoever of fixing it.
As a sample, here's a bug issue in BB Developer Issue Tracker and still unresolved. I've had to deal with hfm in my latest project and also faced issues I had to workaround by creating my own manager, in a similar way as Shashank's answer shows. You can find more examples on creating a custom manager in SO. Also here are covered the basics.
This is currently the only solution, since RIM is transitioning to BB 10 (C++), and they are dumping the Java API, so don't expect them to fix it anytime soon. Even if they were, it won't be fixed but on the latest OS version, which is useless since BB devices are rarely upgraded.
Upvotes: 2
Reputation: 31045
I think Shashank was basically on the right track, but for a more complete example of how to change the ButtonField
width, I would recommend looking at this answer.
Upvotes: 0
Reputation: 512
You need to set editfield width & button width
protected void layout(int width,int height)
{
super.layout(Display.getWidth() * 3 /4 , getpreferedHeight());
super.setExtent(Display.getWidth() * 3/4 , getpreferedHeight());
}
For button use
protected void layout(int width,int height)
{
super.layout(Display.getWidth() /4 , getpreferedHeight());
super.setExtent(Display.getWidth() /4 , getpreferedHeight());
}
Upvotes: 2