[2017-7-25] Android Learning Day3

Source: Internet
Author: User

Recently really a little confused, feel that there is no complete teaching system is difficult to go on, and some are their own blind, just as before, as the time of ACM, and then "This is a water problem violence on the line", "We enumerate all the state, find the law on the line", MMP yo.

But!!!!!!!!!!!!!!!!!!!!!! B Station is omnipotent, there is no!!!!!!!!!!!!!!!!!!!!!

A while ago in the Geek College saw a good Android teaching, I looked at the feeling of teaching a bit chaotic, but feel very full. but!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Sure enough, these sites are for the money, but they can be understood as well. But I still can't afford it, and it turns out Hey hey ~~~~~~~~~~~~~~~~~~~~

No more nonsense, just record today's self-study!

FragmentStep1: Write two fragment layout files, this and the active layout file seems to be the same

That's probably what it looks like.

Left one to the right, so write two layout files.

<!--Left_fragment.xml left-hand layout file -<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"android:orientation= "vertical"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent">    <ButtonAndroid:id= "@+id/button"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:layout_gravity= "Center_horizontal"Android:text= "button" /></LinearLayout><!--right_fragment.xml layout file to the right -<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"android:orientation= "vertical"Android:background= "#0fa4e9"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent">    <TextViewAndroid:id= "@+id/textview"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:layout_gravity= "Center_horizontal"android:textsize= "20SP"Android:text= " This was right fragment!" /></LinearLayout>
Step2: The layout file is added to the main view.
1 <!--Activity_main.xml -2 <?XML version= "1.0" encoding= "Utf-8"?>3 <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"4 android:orientation= "Horizontal"5 Android:layout_width= "Match_parent"6 Android:layout_height= "Match_parent">7 8     <Fragment9         Android:id= "@+id/left_fragment"Ten <!--here to pay attention to the full package name to introduce the layout file--> One android:name= "Com.liwenchi.learnfragment.LeftFragment" A android:layout_width= "0DP" - android:layout_height= "Match_parent" - android:layout_weight= "1"/> the  -     <Fragment -         Android:id= "@+id/right_fragment" - Android:name= "Com.liwenchi.learnfragment.RightFragment" + Android:layout_width= "0DP" - Android:layout_height= "Match_parent" + Android:layout_weight= "1" /> A  at </LinearLayout>
step3: New Rightfragment class and Leftfragment class and inherit from fragment

 Public class extends // Select the fragment under V4     @Override    public  View oncreateview (layoutinflater inflater, ViewGroup container, Bundle savedinstancestate) {        false);         return view;    }}

This will be ok ......

But I still do not know when these two classes were called ...... I'm an object-oriented, really good dish,!!!!!!!!!!!!!.

[2017-7-25] Android Learning Day3

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.