When doing the instructions on the input box, it is much better to use the dynamic input effect than the static picture, this article introduces the implementation of the Android platform analog keyboard input with the function of a search input operation guide which needs to be implemented recently.
On Android do not know how to record GIF dynamic diagram, directly look at the effect of it, specifically to see the demo on the line.
The implementation is simple, open a thread, through the sleep control input character interval time, encapsulates a method of simulating keyboard input, the final code is this:
public class Typeinactivity extends baseactivity {@Overridepublic void Setcontentview () {Setcontentview ( R.layout.activity_type_in_layout);} @Overridepublic void Findviews () {} @Overridepublic void GetData () {} @Overridepublic void Showconent () {showguide ();} public void OnClick (View v) {switch (V.getid ()) {case r.id.searchbtnid:{}break;default:{}break;}} private void ShowGuide () {New Thread (new Runnable () {@Overridepublic void run () {try {thread.sleep ();} catch (Inte Rruptedexception E1) {e1.printstacktrace ();} "Rotation" Pinyin int[] Keycodearray = new Int[]{keyevent.keycode_x,keyevent.keycode_u,keyevent.keycode_a,keyevent.keycode_ N,keyevent.keycode_space,keyevent.keycode_z,keyevent.keycode_h,keyevent.keycode_u,keyevent.keycode_a, keyevent.keycode_n};for (int keycode:keycodearray) {try {Typein (keycode); Thread.Sleep (200);} catch (Interruptedexception e) {e.printstacktrace ();}}}}). Start ();} private void Typein (final int keycode) {try {instrumentation inst = new Instrumentation (); inst.Sendkeydownupsync (keycode);} catch (Exception e) {log.e ("Exception when Sendkeydownupsync", e.tostring ());}}}
Baseactivity.java: (The individual has been used to writing this ...) )
Public abstract class Baseactivity extends Activity {@Overrideprotected void onCreate (Bundle savedinstancestate) { Super.oncreate (savedinstancestate); init ();} private void Init () {Setcontentview (); Findviews (); GetData (); Showconent ();} public abstract void Setcontentview ();p ublic abstract void Findviews ();p ublic abstract void GetData ();p ublic Abstract V OID showconent ();}
then find a simulation of the typing of sound, in the analog input when playing the pronunciation effect, the effects are still possible ...
Implementation of Android analog keyboard input function