Input data into BasicEditField on BlackBerry Torch
I'm writing an app which has a function asking users to type a filename into a BasicEditField on a PopupScreen. The app works fine with Blackberry Storm 2 -- both the simulator and a real device.
The problem is that the app doesn't work on a BlackBerry Torch -- neither the simulator nor a device. I can't enter text into the BasicEditField.
Why doesn't the keyboard on the BlackBerry Torch work with a BasicEditField? I've also tried an EditField instead of BasicEditField开发者_如何转开发 but it doesn't work either.
private BasicEditField txtFileName =
new BasicEditField("Name: ", "", 50, EditField.EDITABLE | EditField.FILTER_FILENAME);
...
Constructor()
{
add(txtFileName);
}
OK, the mistake I made was to put the wrong return value for the keyChar method.
I put
return true;
at the end of the method,
which should be
return super.keyChar(key,status,time);
Below is the correct implementation for the keyChar method:
public boolean keyChar(char key, int status, int time)
{
..................
/*
return true; // user cannot type in the BasicField on Torch, but can type on Storm
*/
return super.keyChar(key,status,time);// works on both Torch and Storm
}
This isn't an answer to your problem, but I have a code snippet that might help. I tried reproducing what you describe above using the following code. It worked without issue:
private static class AppScreen extends PopupScreen
{
AppScreen() {
super(new VerticalFieldManager(), Field.FOCUSABLE);
BasicEditField txtFileName = new BasicEditField("Name: ", "", 50,
EditField.EDITABLE | EditField.FILTER_FILENAME);
add(txtFileName);
}
}
Sorry I don't have a direct answer to your problem, but hopefully the above code can help you track down the problem in your app.
精彩评论