I tried to playing a swf file inside apps on Android 3.0 tablet, by using webView.
Everything was setting as what I did on older version of Android before. But the View kept in a blank gray color and nothing shows up.
The solution is very simple, just put this line into the manifest xml file:
This should be under the Application tag.
Monday, May 23, 2011
Sunday, May 22, 2011
How To: Custom Keyboard in Android 3.0(Step 2: Displaying and Events)
Let's go on with our keyboard.
This post is telling you how to control our new keyboard in activities.
First, you need to implement two listeners called OnKeyboardActionListener and OnKeyListener like:
Next, initial your keyboard view, to apply the design you did in step one. Do this in OnCreate method:
Then add a click event to your editors that make the keyboard appearing:
Here I use a variable called currentEditText to save the touched EditText, in order to tell the keyboard which EditText should append the character:
EditText currentEditText = null; //add it in activity class before OnCreate method
Now, your apps can not be compiled because you should implement methods in Interfaces:
OK, now you can run your apps, when you touch a EditText(if you already have one), the keyboard may appears, touch again, it disappears.
But when you try to touch any key in your new keyboard, nothing happens. Now, we need to work on this.
Remember the codes I talked about on my last post? now we should have something to record the relation ship between the codes and characters.
I'm using a HashMap, surly you can use any other things you want, like, maybe, another XML file, or try to read directory from the keyboard XML file.
Add this in onKey method(or any place you want, but make sure keyCodeMap is visitable in onKey):
Then we should append charaters into the EditView when user press the key. In onKey:
what's "else" working here? codes "-5" is the delete(back) key, so we are going to delete one charater each time user press it.
OK, now the keyboard is finished, but you may find that the default Input Method is still there. We must disable it.
We have many ways to do so, here I'm using the config of the EditText:
If you have any good ideas about disabling the default Input Method, please comment and tell me.
OK, all done, test your custom keyboard in your own apps, have Fun!
Comment this post if you have any question, or you find any problem on my post.
This post is telling you how to control our new keyboard in activities.
First, you need to implement two listeners called OnKeyboardActionListener and OnKeyListener like:
Next, initial your keyboard view, to apply the design you did in step one. Do this in OnCreate method:
Then add a click event to your editors that make the keyboard appearing:
Here I use a variable called currentEditText to save the touched EditText, in order to tell the keyboard which EditText should append the character:
EditText currentEditText = null; //add it in activity class before OnCreate method
Now, your apps can not be compiled because you should implement methods in Interfaces:
OK, now you can run your apps, when you touch a EditText(if you already have one), the keyboard may appears, touch again, it disappears.
But when you try to touch any key in your new keyboard, nothing happens. Now, we need to work on this.
Remember the codes I talked about on my last post? now we should have something to record the relation ship between the codes and characters.
I'm using a HashMap, surly you can use any other things you want, like, maybe, another XML file, or try to read directory from the keyboard XML file.
Add this in onKey method(or any place you want, but make sure keyCodeMap is visitable in onKey):
Then we should append charaters into the EditView when user press the key. In onKey:
what's "else" working here? codes "-5" is the delete(back) key, so we are going to delete one charater each time user press it.
OK, now the keyboard is finished, but you may find that the default Input Method is still there. We must disable it.
We have many ways to do so, here I'm using the config of the EditText:
If you have any good ideas about disabling the default Input Method, please comment and tell me.
OK, all done, test your custom keyboard in your own apps, have Fun!
Comment this post if you have any question, or you find any problem on my post.
How To: Custom Keyboard in Android 3.0(Step 1: Custom Keyboard design)
I think some of you may have same problem in Android 3.0 tablet:
Unable to disable some keys in it's new default Input Method, like "Input Method Options" key and "Voice Input" key.
And we may have other friends that just want to disable the Input Methods in their apps.
This post may help you on how to create a custom keyboard in your own apps.
*NOTE: This post is not telling you how to make a Input Method app*
First, you need to create a new XML file using for custom interface of your keyboard, this is easy on Android SDK because we have a UI Element called "Keyboard".
Here's one sample keyboard interface code:
(Anyone who knows how to paste code as a "code clip" in this blogspot, can tell me)
Here are two important sub elements:
Using any codes that you think is easier for you to remember.
OK, now you can add your custom keyboard into any place you want, like:
or if you want it always displaying at the bottom:
Now, we have a new keyboard!
Next Step post, we are going to work on activity's code, on display/hide keyboards, and also key press event catch.
Unable to disable some keys in it's new default Input Method, like "Input Method Options" key and "Voice Input" key.
And we may have other friends that just want to disable the Input Methods in their apps.
This post may help you on how to create a custom keyboard in your own apps.
*NOTE: This post is not telling you how to make a Input Method app*
First, you need to create a new XML file using for custom interface of your keyboard, this is easy on Android SDK because we have a UI Element called "Keyboard".
Here's one sample keyboard interface code:
(Anyone who knows how to paste code as a "code clip" in this blogspot, can tell me)
Here are two important sub elements:
- Row: each Row here is a new line for your keyboard, you can have as much rows as you want.
- Key: each Key here is a touch key with touch effects, like a big character box telling you which key is pressed.(Yes, the "Keyboard" element is so good that it already has this!)
Using any codes that you think is easier for you to remember.
OK, now you can add your custom keyboard into any place you want, like:
or if you want it always displaying at the bottom:
Now, we have a new keyboard!
Next Step post, we are going to work on activity's code, on display/hide keyboards, and also key press event catch.
I'm Here!
Hello, everyone. I'm here on blogspot with blogger now, sharing my experience on Android and iOS development.
Also I will share interesting food, hmm, maybe, all over the world later, but based on GZ/China right now.
Also I will share interesting food, hmm, maybe, all over the world later, but based on GZ/China right now.
Subscribe to:
Posts (Atom)