Beginners Learn Android 1: New entry encounters with some little pits

Source: Internet
Author: User

Development environment has long been installed, has not been done. Today is a record here, but also a supervision of their own.

Development environment:

Win7 System, the official website download Adt-bundle-windows, contains the eclipse and the Android SDK, did not use Android Studio mainly consider the current most people use or eclipse, encountered a problem is better solved.

1, using the Sdkmaneger installation API each version is quite slow.

You can actually download or copy the corresponding version of the file and drag it directly to the Sdk/platforms directory. or set up a proxy server in tools->options to install or update it using an open source image station in a domestic university or institution.

2, EditText is not found when using layout layouts

Eclipse uses the Android 4.4W version of API 20 by default, which is available to wearable devices without edittext.

Change a lower version, (General mobile app, according to the user group's attributes, select the appropriate version)

3,onclicklistener cannot is resolved to a type

Btn_login.setonclicklistener (New Onclicklistener () {    @Override public    void OnClick (View v) {        //TODO auto-generated method Stub        toast.maketext (Loginactivity.this, "Login Successful", Toast.length_short). Show ();    });    

The above error occurred because the "Onclicklistener" interface was moved to the view class after the Android version was upgraded.

Workaround: Change "new Onclicklistener" to "new View.onclicklistener", or use Eclipse to automatically import all related Java packages with shortcut keys: "Ctrl+shift+o"

Import Android.view.View.OnClickListener;

4,progressbar will occupy the location of the layout

If you want to use ProgressBar to do loading status display, it might not be ideal for simple layout implementations. Here do not delve into the ProgressBar of the application of the scene, just a simple solution to my problem.

In LinearLayout and Relativelayout, when the ProgressBar is visible, it occupies space in the layout and squeezes the normal control position. Using Framelayout can be achieved, but more complex.

, the button is squeezed to the next line. The simple implementation of masking loading can be done with ProgressDialog, a few lines of code.

ProgressDialog Progress_dialog = new ProgressDialog (mainactivity.this);pd _login.setmessage ("Loading ...");PD _ Login.show ();

Feel the Android version problem, more chaotic, any heavy and long way, sleep.

Beginners Learn Android 1: New entry encounters with some little pits

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.