2
votes

I need help with my app, There are 4 Problems which I am facing:- 1) The scenario goes as follows:

  • Start the app 
  • Enter details like password and all 
  • Exit the app after that

When I again start the app, I want all fields to be blank. I'm not able to find a method/function that will help me do that.

2) I tried saving text from textarea but nothing was saved after first space. I tried using buffered input/output stream but getting an error.

3) Most importantly, when I run the app on my Samsung Galaxy S duos (didn't test on other devices), it's giving me error/exception java.lang.NoclassDefFoundError: org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher but its running fine on emulator.

4) Lastly, how do I set container layout and make it scrollable?

1
You have 4 separate questions here which makes it very hard to answer all of them correctly or consistently. It might put off people who don't know the answer to all 4 questions and slow your response time. I suggest asking separate questions which is totally fine with us. Thanks. - Shai Almog

1 Answers

2
votes

If you exit an app in codename one, any text you entered in textfields are automatically cleared, unless you added the text in Gui builder or code before runtime or specifically instruct your app to store them and retrieve them when the app runs again.

This applies for the case of application exit however an application can be minimized/restored... In which case if you want to clear the text you can detect that thru either the stop() method that is invoked on minimize or the start() method that is invoked every time your app is restored. You can test it in the simulator using the suspend/resume option.

You can save some text to be accessed later using codenameone Preferences. What line of code is throwing that exception?

This is how you create a scrollable container in code:

Container test = new Container(new BoxLayout(BoxLayout.Y_AXIS));
test.setScrollableY(true);

Notice that by default the content pane of the form is scrollable on the Y axis unless you set it to a border layout (which inherently doesn't scroll).

I'm assuming you got the bouncy castle error because you changed the classpath of the project. You need to use cn1libs such as the one for bouncy castle and only use API's supported by the cn1libs.