• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help on KeyPressed()?

 
Robin Thapa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I have two java classes here.

------------------------------------------------------------------------------------
Services.java


-----------------------------------------------------------------------------------
TCanvas.java


------------------------------------------------------------------------------------


The problem i have here is i can display the image but i have a problem to navigate through the images&text .ie in the emulator it displays (image and Text).
For eg in emulator i can see:
--------------------------------------
Services
About Us
Contact Us

Exit Show
-------------------------------------------
Now i want to use a keyPressed(int keyCode);
but how do i do that, coz my image is on canvas and im not being able to use the above keyPressed(int keyCode) method.

Please help me.

Robin Thapa
services.PNG
[Thumbnail for services.PNG]
 
Peter Miklosko
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you start screen make one of the option highlighted-selected by default (draw rectangle with perhaps different colour then background and change style of text, bolder, different colour or font), have variable that holds a data on currently selected option. Create method for traverse and rest should be easy to finish once you know which option is selected.

PS: there is small difference on returned button press between emulator and real device. One return for example UP and the other Up. So watch out for these...
 
Robin Thapa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter Miklosko wrote:When you start screen make one of the option highlighted-selected by default (draw rectangle with perhaps different colour then background and change style of text, bolder, different colour or font), have variable that holds a data on currently selected option. Create method for traverse and rest should be easy to finish once you know which option is selected.

PS: there is small difference on returned button press between emulator and real device. One return for example UP and the other Up. So watch out for these...



Could you please just help me with my codes just to select the image? i mean can you help me to make a button kind of over those three......
 
Peter Miklosko
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have look at this example, it is not pretty but it show how it can be done
 
Maneesh Godbole
Saloon Keeper
Posts: 11165
14
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robin,
In future, while posting code, please use code tags
 
Robin Thapa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter Miklosko wrote:Have look at this example, it is not pretty but it show how it can be done


Dear Sir,

I am really thankful to you for your help and Support.
 
Robin Thapa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sir,

I have done it to some extend and im now able to navigate through the list.
I got into a small problem,

public void commandAction(Command c, Displayable d) {
if (c == backCommand) {
CanvasListMidlet.quitApp();
} else if (c == selectCommand) {
if (selectedIndex == 0) {
/// here i wish to call another canvas which consists of another List as in the examples class as:MessagesMenuScreen
// i tried calling another canvas class but i am not able to get it done.
// please help me

}
}
}


Your's
Robin Thapa
 
Robin Thapa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The above problem is actually sloved.

Thank you
 
Robin Thapa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sir,

Now i came into a big problem........... everything accomplished as i wanted.
But i read that we cannot create a textfield in a canvas.
So how do i accomplish it?
When user selects a list, i want them to enter something.
So how do i use a textfield in canvas?
or how can i create a textfield in canvas?please help me

Robin Thapa
 
Peter Miklosko
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Option A) Write your own TextField class that will be draw on Canvas (this is actually over kill, but if you think it would look better in your application then by any means do it)

Option B) On list selection redirect user to next screen with TextArea and collect user data and process them (returning back and showing them as part of list just in different font, decission is yours as I have no idea what you are up to)
 
Robin Thapa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sir,

My Project is a simple one.
I have to build the interface using canvas.
and almost all the interface is done, except when an menu item is clicked , it should display a textfield where a client can enter some inputs.

I have almost done it.

I did as you said in the earlier post.
Can i fill some color on the form so that the UI is inconsistency.

Please help me.
If you give me ure email id i would like to share my project with you.

Thanking you,

Robin Thapa

 
Dushyant Chhetri
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Robin,

I would love to learn from your project
my email : dushdushyant@gmail.com

thanks in advance..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic