It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
how to get a field press event in blackberry。
I write a component extends Field class , want to get a press event( press down still not press up ) .
please help me.
You can override this method:
protected boolean keyDown(int keycode, int time)
About the key up presses, there's a keyUp which is the method you should override to perform an action when the key is released instead of pressed (you can press and hold, and the action doesn't normally get fired until released). However, the OS doesn't callback on key up events unless it is explicitly told to do so by your app, for performance reasons.
You can overide keydown method of any field variable , or you can override navigationClick method of click
public ButtonField btn = new ButtonField("Hello");
protected boolean navigationClick(int status, int time)
{
Field f1 = getFieldWithFocus().getLeafFieldwithFocus()
if(f1 == btn)
{
<Perform your business logics>
}
Thanks
Related
I'm fairly new to writing BlackBerry applications, so maybe this is a stupid thing I'm overlooking. I have to use JDE 5 (client requirement) to support the older BlackBerry Curve 8520 phones.
What I am experiencing is that as soon as I place a DateField on my interface, the application slows down considerably, causing the UI to stutter. Even a simple layout that only has a single DateField and a button has the same effect. Then, as soon as I move on to the next layout, everything is fine again.
One of the layouts are created as follows (please comment if this is the incorrect way of doing it):
public void displaySomeLayout() {
final ButtonField okButton = new ButtonField("OK");
final DateField dobField = new DateField("Birthday", System.currentTimeMillis(), DateField.DATE);
/* some other non-ui code */
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
applicationFieldManager.addAll(new Field[] {
dobField,
okButton
});
}
});
}
The application then just slows down a lot. Sometimes, after a minute of so it starts responding normally again, sometimes not.
The displaySomeLayout() method is called from the contructor of the Screen extending class. And then applicationFieldManager is a private VerticalFieldManager which is instantiated during class construction.
I'm not sure the problem is in the code that you've shown us. I think it's somewhere else.
However, here are a couple recommendations to improve the code you've shown:
Threading
First of all, the code you show essentially is being run in the Screen subclass constructor. There is almost no difference between this code:
public MyScreen() {
Field f = new ButtonField("Hello", ButtonField.CONSUME_CLICK);
add(f);
}
and this:
public MyScreen() {
addField();
}
private void addField() {
Field f = new ButtonField("Hello", ButtonField.CONSUME_CLICK);
add(f);
}
So, because your code is being run in the screen class's constructor, it should already be running on the UI thread. Therefore, there's no reason to use UiApplication.getUiApplication().invokeLater() here. Instead, just use this:
public void displaySomeLayout() {
final ButtonField okButton = new ButtonField("OK");
final DateField dobField = new DateField("Birthday", System.currentTimeMillis(), DateField.DATE);
/* some other non-ui code */
applicationFieldManager.add(dobField);
applicationFieldManager.add(okButton);
}
Sometimes, you do need to use invokeLater() to run UI code, even when you're already on the UI thread. For example, if your code is inside the Manager#sublayout() method, which runs on the UI thread, adding new fields directly will trigger sublayout() to be called recursively, until you get a stack overflow. Using invokeLater() can help there, by deferring the running of a block of code until sublayout() has completed. But, from the constructor of your screen class, you don't need to do that.
ObjectChoiceField
I'm also worried about the ObjectChoiceField you said you were using with 250 choices. You might try testing this field with only 10 or 20 choices, and see if that makes a difference.
But, even if the 250 choice ObjectChoiceField isn't the cause of your performance problems, I would still suggest a different UI.
On BlackBerry Java, you can use the AutoCompleteField. This field can be given all the country choices that you are now using. The user starts typing the first couple letters of a country, and quickly, the list narrows to just those which match. I personally think this is a better way to get through a very large list of choices.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I'm writing a program for parsing xml file I need to continually read the file that means if any change happens to the xml file at run time it must shown in the simulator also
I tried
NSThread *myThread =[[NSThread alloc]initWithTarget:self selector:#selector(doParsing) object:nil];
[myThread start];
and it calls the xml file but its not showing the change .How can I achieve that
Possibly something like:
NSThread *myThread =[[NSThread alloc]initWithTarget:self selector:#selector(callTimer) object:nil];
[myThread start];
- (void)callTimer
{
[NSTimer scheduledTimerWithTimeInterval:10.0
target:self
selector:#selector(doParsing)
userInfo:nil
repeats:YES];
}
- (void)doParsing
{
//Do the stuff here
}
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
.h
#property (strong, nonatomic) IBOutlet UITextField *responsibleField;
.m
#synthesize responsibleField;
responsibleField.text = [goal valueForKeyPath:#"responsibility.actorNaam"];
and actorNaam is of type String in my datamodel ..
and my textfield is correctly connected
Error:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFSet _isNaturallyRTL]: unrecognized selector sent to instance 0x6e8e9d0'
What could be wrong?
[goal valueForKeyPath:#"responsibility.actorNaam"]; is returning an object of type NSSet responsibleField.text is expecting an NSString. Check your code where you set the value for key path responsibility.actorNaam.
The object at goal.responsibility is an NSSet, invoking valueForKeyPath: on an NSSet returns an NSSet of the values at the specified keypaths.
If you just want to "pick one" from the set, use this:
[ [ goal valueForKeyPath:#"responsibility.actorNaam" ] anyObject ] ;
i.e. the question is which responsibility do you want?
I am working with 2 resolutions one touchScreen and other Non- touch
i have designed a Screen which has 10 custombuttons are added to a VerticalFieldManager
The CustomButtonField class extends Field class
i have used 2 methods fieldChange() and touchEvent() for touchScreens
the problem is whenever i do click on button it gets activated correctly for touchevent()
but then the fieldChange() method also gets called immediately afterwards
what should i do??
what's the problem ??
Check the answers of the question BlackBerry touchEvent outside Field triggers fieldChanged provided by Paul Sylliboy and Arhimed.
In those answers, there was a method which only updates a boolean variable to identify that a touch event occured, and based on the value of that boolean an action is executed on the fieldChanged or navigationClick method.
BB UI Framework calls navigationClick(int status, int time)
automatically if there is any touch event after execution of
protected boolean touchEvent(TouchEvent message). And
navigationClick(int status, int time) calls the method
fieldChangeNotify(0) which causes fieldChange() (in the question)
or public void fieldChanged(Field field, int context) to be called.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
My servlet on receiving first request from client:
//1.
ObjectInputStream in=new ObjectInputStream(req.getInputStream());
String r=(String) in.readObject();
in.close();
ObjectOutputStream writer = new ObjectOutputStream(resp.getOutputStream());
writer.writeObject(pk);
writer.close();
//ON receiving second request:
//2.
ObjectInputStream in1=new ObjectInputStream(req.getInputStream());
String s=(String) in1.readObject();
in1.close();
OutputStreamWriter writer1 = new OutputStreamWriter(resp.getOutputStream());
writer1.write(reverseStr);
writer1.close();
But on both request only 1. is getting executed. why?
I asked this question without actually studying servlets. A servlet's method(doPost(),doGet() etc) are each called time a request is made to the servlet. Only the init() method is initialized or executed only once.
So each time a call is made to the above servlet, it starts executing from #line1.