Configuration parameters for Android development help write code one

Source: Internet
Author: User

In the normal development of Android, the process is this, the interface needs to be displayed first, in sending an HTTP request. Access URL. Key, value, gets the data in the parsing, set to the view inside, such a major process is over, the function is basically intact. I have just started to write that Android thought it was very passionate, but then I thought it was too much trouble. Writing code is the ability to standardize everything in a regular way, then the above development process is completely regular to find, then we can also write code to unify the law.

I've been thinking about ways to simplify the development process. I suddenly mean that when we draw the layout, we use an XML file to draw the layout, so we can also have the configuration parameters to unify the code above, and say the origins of some ideas. Finally back to the topic configuration parameters to help us write code. I'm going to configure this parameter in the layout file. Later, just need to write in this file configuration parameter information, all the rest of the steps to let the code to help us finish. Since it is the configuration of the reference code, then we have to configure the parameters to make the code read, so we have to develop a reading of these parameters of the tool class.

Write a well-written success story first. Look at the following code is not very easy to write. If it is simple, the next issue will be updated Oh!

1. Configure the parameters of the HTTP request in value,
<string-arrayname="Yn_login">    <!--settings url-->    <item>Url:http://www.baidu.com</item>    <!--The key that needs to be passed to the server, the corresponding value will be passed in by code --    <item>Key:username,userpassword</item>    <!--callback Markers--    <item>call:666</item></string-array>
2, next write good layout file, the following login button is the focus, here I just write login button
<com.yn.yn.util.view.review.yntextviewxmlns:app="Http://schemas.android.com/apk/res-auto"    Android: id="@+id/btn_regiter"    style="@style/hfh_lager_button_red_click_hollow"    Android: layout_margintop="30DP"    Android: gravity="Center"    Android: text="Login"    app: onclick="http"    app: onclickvalue="@array/Yn_login" />
<!--app:onclick= "http"  to send HTTP requests, including jump activity--><!--app:onclickvalue= "@array /yn_login "   Configure the parameters to send HTTP requests--
3. Get the object of the button and set the listener. There will be three methods that need to be implemented, the first method returns the account and password that sent the login request, the second is the callback with the button clicked, and the third method is the callback for the successful network request.
According to the requirements of the above implementation.
Mbutton.setonbacklistener (NewOnynbacklistener () {@Override PublicString[] Gethttpvalue () {//This method is to transfer the account number and password to the server        Musername = Et_username.gettext (). ToString ();        Mpwd = Et_pwd.gettext (). ToString ();return newString[]{musername, MPWD};    } @OverridePublic voidOnitemclick (View view, intPosition, Object data) {Super. Onitemclick (view, Position, Data;        //Click on the login button    } @OverridePublic voidOnEnd (View view, intPosition, Object data) {//Callback Interview Network Success object        Toastutil.showsuccess ("Successful Landing");    }});

All right. Have not seen a network request super simple, you need to write the code on the simple lines!! The next issue I will update is how to implement this above code.

What good advice can QQ contact 382034324

Configuration parameters for Android development help write code one

Related Article

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.