I am implementing tabs. I have five tabs. For each tab i am calling screen in following way. In
displayTab1() function i am calling another class, It is easily loading MyScreen class but problem is for first time it is showing me same fields two times and whenever i click on this tab same fields are added continously. I have used delete(tabArea);
public VerticalFieldManager displayTab1()
{ MyScreen loadingScreen = new MyScreen();
tab1Manager.add(loadingScreen);
return tab1Manager;
}
Please let me know where i am doing wrong
Thanks
I solved this, In onFocusChanged() i first deleted the whole fields of tab1 by using tabManager1.deleteAll() and after that i added.
Related
I searched how to set header and footer in BlackBerry and I found the functions setTitle() and setStatus().
My problem is I have created a class that extends VerticalFieldManager. In VerticalFieldManager, it is not showing me setStatus function as this is function of MainScreen class.
You're right. A VerticalFieldManager does not allow you to setStatus() directly.
It's important to understand the relationship between the classes in the BlackBerry UI framework.
First of all, there are Screen classes. Normally, a Screen will take up the entire device screen. You can have many different Screen classes in your app. Maybe one Screen for a splash image, one screen for a map view, one screen for settings, etc.
Inside your screens, you will often have Manager classes. A VerticalFieldManager is a kind of Manager that arranges its contents top-to-bottom, in the order that you add them. A Manager holds a group of related objects, but it does not have to span the full screen height, or width.
Inside your managers, you will usually have multiple Field objects. A Field is the individual item in the heirarchy. ButtonField, EditField, or BrowserField are all kinds of fields. They will usually be added to managers (containers). Those managers will then usually be added to screens.
So, in your case, I think what you should have is a screen class. In that screen class, you will set the header and footer by calling setTitle() and setStatus(). The content between the header and footer will all be contained in a VerticalFieldManager that you add to the screen. Something like this:
public class MyScreen extends MainScreen {
public MyScreen() {
super(MainScreen.VERTICAL_SCROLL | MainScreen.VERTICAL_SCROLLBAR);
// set a header for this screen
setTitle("My Header / Title");
// screen contents go in the vertical field manager
// NOTE: you can replace VerticalFieldManager with your own class
// that extends Manager, or VerticalFieldManager, if you like
VerticalFieldManager vfm = new VerticalFieldManager();
vfm.add(new LabelField("One"));
vfm.add(new ButtonField("Two", ButtonField.CONSUME_CLICK));
vfm.add(new CheckboxField("Three", true));
add(vfm);
// use a bitmap as a footer
Bitmap footer = Bitmap.getBitmapResource("footer.png");
setStatus(new BitmapField(footer));
}
}
I am using a custom textbox field,and am trying to change the text programmatically using setText...
It's working for the first field, but not for the second field...
Could someone help me out here...the text to be set is getting sent into the custom textbox , but the edit field.settext works only for the first instance of the textbox...
I can't post the code right now, but will try to give a better understanding-
I have 4 text boxes in one page,with a key listener added to the page.( this is to facilitate transliteration-English to Gujarati )
I added a int value to keep track of which field has focus, and used that to call set text method on the appropriate field.
The correct method gets called, with the correct value, and still only the first text box field's value gets reset...I used debug to follow the flow, right upto the point where the edit field.setText gets executed.
I tried the same with simple edit fields instead of custom fields, and got the same result...
The setText gets executed properly when the keylistener is not active though...
So I am stumped as to what is causing the problem.
Will add the keylistener code and any other relevant code by the day end.
Please try following code:
import net.rim.device.api.ui.component.TextField;
import net.rim.device.api.ui.container.MainScreen;
public final class MyScreen extends MainScreen
{
TextField tempTextBox;
public MyScreen()
{
// Set the displayed title of the screen
setTitle("MyTitle");
tempTextBox = new TextField("Titile: ", "Fitst Detail");
this.add(tempTextBox);
tempTextBox.setText("Second text");
tempTextBox.setText("Third Text");
}
}
if not refresh screen then you can set
invalidate();
after serText method.
hope help full.
well, with the death of blackberry, this is not really going to help anyone, but at the same time , this question has been open for 2 years, so i decided to close it :-)
We solved the issue by having separate keylisteners for each textbox. Thank you for the assistance. –
I am trying to create a customized list field where, I have more then 2 clickable buttons in each row. For that i have customized the HorizontalFieldManager and created own manager to align the field elements. Now UI is perfectly fine.
But, I am struggling to handle the events work for both.
Step-1 I have used fieldChangedListener for buttons added in row. It is working fine
public void fieldChanged(Field field, int context) {}
step-2 have used navigation click to handle event on the parent manager.
protected boolean navigationClick(int status, int time) {
Field field = getFieldWithFocus();
Dialog.alert("shops field clicked");
return super.navigationClick(status, time);
}
Now, even the navigationClick event works. But as the button is the child field added to VFM. When i click on the button both the VFM and button event comes together.
How could i restrict only to the button while it is clicked on the ButtonField.
If I understood your question correctly, you want the navigationClick() to be called only for the child field (clickable button) without being called for the manager. Sorry to disappoint you, but you can't.The navigation click event will always be called first for the manager and only than the manager will propagate the event to the child field. The same hold for keys events, touch events, focus events and etc...
Describe what you are trying to achieve, add a code snippet and I am sure we will find a solution.
I am working on a project where I need to display a ListField that takes the top half of the screen when the user clicks on a menu item. It should display on top of the earlier screen. How can I implement it?
Here are my ideas:
Use ListField directly with the above screen size to required screen.
Use PopupScreen with ListField
Use some screensplit functionality to display half of the screen
PopupScreen is best fit for your question. Can you try and post the code that didn't work?
Another option is to use managers to split the screen (higher manager and lower manager) and to hold another two managers: one that will be displayed on click and one that will be used as a pointer to the displayed Manager. Then, when ever the replace event is fired you should call the following function:
void updateManagers(boolean click)
{
if(click)
{
currentManager = afterClickManager;
}
else
{
currrentManager = beforeClickManager;
}
invalidate();
}
Where currentManager is an instance of Manager and afterClickManager & beforeClickManager are instances of some class which extends Manager (no need to be the same class).
Note that you should add currentManager to your screen layout before using the invalidate function.
I'm running into the following scenario on some devices: when the use clicks on field and expects an response, instead of properly responding to that click event, the device shows the context menu at the bottom center of the screen.
navigationUnclick and trackwheelUnclick
From what I've read, I can override navigationUnclick and trackwheelUnclick to prevent the menu from showing. I'm doing this as the screen level but reproducing the centered-menu scenario is difficult. Is this the correct approch?
Why does this happen? Is there any way to resolve this?
I recently had this happening. I was extending MainScreen to provide some basic functionality, but didn't want the context menus. Returning true from navigationClick() removed this behavior.
public class MyScreen extends MainScreen {
protected boolean navigationClick(int status, int time) {
/*
... custom behavior ...
*/
return true;
// the following line would trigger the context menu
//return super.navigationClick(status, time);
}
}
I didn't need to override navigationUnclick() at all. Unlike #JustinD's approach with override onMenu(), this only prevents the menu from this certain case -- not across the entire screen (which you may want, and that would probably be a better way to do it).
Anyway, that's been my experience with clicks and menus recently.
Can you post your code? Try overriding trackwheelClick and navigationClick instead of the Unlick methods. Also make sure you return true in these methods.
If you override onMenu and just return true (you handled the menu event) then the menu will not show up...assuming you don't need a full menu either - if you want full menu and not context menu then just do what Jan said and you should be fine - make sure to return true or else the event will bubble up and end up with the menu being generated
public class MyClass Extends MainScreen
{
///
// Override onMenu to prevent menu from coming up when you click trackwheel
public boolean onMenu(int instance)
{
return true;
}
}
You could use CONSUME_CLICK style on all Fields in your MainScreen...