Android Development Note (a) Android studio IME

Source: Internet
Author: User

Used to be used when the data to do some additions can be, now determined to learn under the system.

First found developer. Android.com started Android studio on development tools, but he didn't have an SDK manager himself and had to download this. Then set the next SDK directory to use. The directory and name of the new project are also somewhat different from the previous ADT development tools. But res,src these are the same. So it is possible to develop together more than two people.

The first big difference is that the Androidmainfest.xml file, which has less content than ADT, is partially moved to Build.gradle because Android Studio uses Gradle to build the project, such as the minimum Android version of the requirements and so put into this file. Here's A

The second instance has an input box and then uses a piece of code that automatically hides the keyboard.

Im_ctrl = (Inputmethodmanager) getsystemservice (Context.input_method_service);

Im_ctrl.hidesoftinputfromwindow (User_name.getwindowtoken (), 0);

The way to display the keyboard is im_ctrl.showsoftinput (EditText, 0);

There's another one. If you want to display the input keyboard in the application, you can not directly use the Showsoftinput method, can not be set directly in the OnCreate, you must wait until the view drawing event is finished to pop up, need to use the Timer auxiliary implementation, if you want to implement the input function, EditText must be given the focus.

protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);

user_name = (EditText) Findviewbyid (r.id.user_name);
Btn_ok.setonclicklistener (Ok_handle);
Im_ctrl = (Inputmethodmanager) getsystemservice (Context.input_method_service);

Timer timer = new timer ();
Timer.schedule (New TimerTask () {
@Override
public void Run () {
Looper.prepare ();
Inputmethodmanager IMM = (inputmethodmanager) MainActivity.this.getSystemService (Input_method_service);
Imm.togglesoftinput (0, inputmethodmanager.hide_not_always);
Toast.maketext (Mainactivity.this, "Hello", Toast.length_long). Show ();//This line does not reflect, do not know what reason, to add this line, must have the front Looper.prepare ();
}
}, 1000);

Here is a looper.prepare (); the problem. The reason for this is that this problem occurs because Android cannot refresh the UI thread in a child thread. Maybe that's why I didn't see the hint.

Prohibit pop-up input keyboard is set below, do not know when to use, first know the next.

Android:name= ". Clientsearchviewactivity "
Android:label= "@string/app_name"
android:screenorientation= "Portrait"
android:windowsoftinputmode= "Adjustunspecified|statehidden"
android:configchanges= "Orientation|keyboardhidden" >

Android Development Note (a) Android studio IME

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.