La especificación de ancho y altura para Editfield hace una dificultad para ver el texto en BlackBerry
-
16-11-2019 - |
Pregunta
He usado EditField
con algunos anchos y altura específicos que funcionan bien, pero, cuando ingreso el texto en EditField
, no puedo ver el texto y algunas veces, cuando estoy haciendo clic en que estoy obteniendo NullPointerException
.No puedo entender si el texto se ingresa o no.Además, no puedo ver el cursor en mi campo.Si hay algún error, por favor dame sugerencias.
Mi código es:
private EditField edto;
private int tosetWidth =400 ,tosetHeight = 50;
public WelcomeScreen()
{
/* Border For EditFields */
Border bdr = BorderFactory.createRoundedBorder(new XYEdges(4, 4, 4, 4),Border.STYLE_SOLID);
edto = new EditField(){
protected void layout(int width, int height)
{
setExtent(tosetWidth, tosetHeight);
}
};
edto.setBorder(bdr);
Solución
Text not showing because of this
protected void layout(int width, int height)
{
setExtent(tosetWidth, tosetHeight);
}
just remove and try your code is working
if you want to edit field with vertical scrolling and fixed size try following
/**
* A class extending the MainScreen class, which provides default standard
* behavior for BlackBerry GUI applications.
*/
public final class MyScreen extends MainScreen
{
/**
* Creates a new MyScreen object
*/
public MyScreen()
{
// Set the displayed title of the screen
setTitle("My Edit box Example");
VerticalFieldManager vr=new VerticalFieldManager(VERTICAL_SCROLL|VERTICAL_SCROLLBAR)
{
protected void sublayout(int maxWidth, int maxHeight) {
super.sublayout(200,100);
setExtent(200, 100);
}
};
Border bdr = BorderFactory.createRoundedBorder(new XYEdges(4, 4, 4, 4),Border.STYLE_SOLID);
EditField edto = new EditField(){
public void paint(Graphics g)
{
getManager().invalidate();
super.paint(g);
}
};
vr.setBorder(bdr);
vr.add(edto);
add(vr);
}
}
you can get output as following
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow