[2017-7-25]Android Learning Day3

最近真的有点迷茫,感觉没有一个完整的教学体系很难进行下去,有的都是自己瞎捉摸,就跟以前ACM的时候一样,动不动就“这就是一道,水题暴力就行了”、“我们枚举一下所有的状态,找一下规律就行了”,mmp哟。

不过!!!!!!!!!!!!!!!!!!!!!!B站简直就是万能的有没有!!!!!!!!!!!!!!!!!!!!!

前段时间在极客学院上看到了不错的Android教学,我看了看感觉教的有点乱,但是感觉很全。But!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

果然这些网站就是为了收钱哦,不过也可以理解啦。但是还是 买不起,结果嘿嘿嘿~~~~~~~~~~~~~~~~~~~~

废话不多说,快记录一下今天的自学!

Fragment

step1:写好两个Fragment布局文件,这个和活动的布局文件好像是一样的呢

大概就是这个样子咯

左边一个右边一个,所以要写两个布局文件。

<!-- left_fragment.xml 左边的布局文件 -->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android: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 右边的布局文件 -->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:background="#0fa4e9"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:textSize="20sp"
        android:text="This is right fragment!" />
</LinearLayout>

step2:讲布局文件添加到主视图里哦

 1 <!-- activity_main.xml -->
 2 <?xml version="1.0" encoding="utf-8"?>
 3 <LinearLayout xmlns: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     <fragment
 9         android:id="@+id/left_fragment"
10         <!-- 这里要注意完整的包名来引入布局文件 -->
11         android:name="com.liwenchi.learnfragment.LeftFragment"
12         android:layout_width="0dp"
13         android:layout_height="match_parent"
14         android:layout_weight="1" />
15
16     <fragment
17         android:id="@+id/right_fragment"
18         android:name="com.liwenchi.learnfragment.RightFragment"
19         android:layout_width="0dp"
20         android:layout_height="match_parent"
21         android:layout_weight="1" />
22
23 </LinearLayout>

step3:新建RightFragment类和LeftFragment类并继承自Fragment

public class LeftFragment extends android.support.v4.app.Fragment{ //选择v4下的Fragment
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.left_fragment, container, false);
        return view;
    }
}

这样就OK啦。。。。。。。。。。。。

但其实我还是不知道这两个类在什么时候被调用的。。。。。。。。。我面向对象真的好菜啊!!!!!!!!!!!!!

时间: 2024-08-29 07:44:52

[2017-7-25]Android Learning Day3的相关文章

25 Android中dip、dp、sp、pt和px的区别

http://blog.sina.com.cn/s/blog_6499f8f101014ipq.html 25 Android中dip.dp.sp.pt和px的区别,布布扣,bubuko.com

新手程序员 工作日志 2017.7.25.18:02 关于改bug网页的使用

责人这里看哪个是自己名下的bug  点进去 点bug对应的ID号进入 综合部-赵鑫 2017/7/25 17:40:47 改完bug修改下bug的状态  附加意见那里可以增加自己的意见 可写也可不写  完成后 点击储存变更

Becoming inspired (2) - ASC 2017 March 25

Becoming inspired - part 2 @ Advanced Studio Classroom Vol: 2017 MARCH 25 7.Who was I like as a child? Let your inner child resurface in your thoughts. Look at a childhood photo of yourself. If you're truly to this person, what would you be doing to

2017.11.25【NOIP提高组】模拟赛A组

2017.11.25[NOIP提高组]模拟赛A组 T1 3467. [NOIP2013模拟联考7]最长上升子序列(lis) T2 3468. [NOIP2013模拟联考7]OSU!(osu) T3 3472. [NOIP2013模拟联考8]匹配(match) T1 有转移方程f[i]=max{f[j]}+1,a[j]<a[i] 可以用线段树+离散化维护这个方程,因为涉及以往状态可以用主席树维护 打太丑爆空间了 Code 1 #include<cstdio> 2 #include<c

[2017-8-2]Android Learning Day8

自定义动画效果 新建一个customAnim类 1 package com.liwenchi.myapplication; 2 3 import android.view.animation.Animation; 4 import android.view.animation.Transformation; 5 6 import static java.lang.Math.*; 7 8 /** 9 * Created by VULCAN on 2017/8/2. 10 */ 11 12 publ

[2017-7-26]Android Learning Day4

RecycleView 恩,学习Fragment的过程中的一个小实践居然用到了RecycleView!坑了我好久有木有!!好气哦,从昨晚到现在.(现在也还是一头雾水,不过照搬也会用了) 这是第一版的代码,都写在 MainActivity.java 里了. 1 public class MainActivity extends AppCompatActivity { 2 3 private RecyclerView rv; 4 private ArrayList<String> datas =

Android 笔记 day3

短信发送器 电脑弱爆了,开第二个emulater要10min!!! 顺便学会查看API文档 1 package com.example.a11; 2 3 import java.util.*; 4 5 import android.app.Activity; 6 import android.os.Bundle; 7 import android.telephony.SmsManager; 8 import android.view.Menu; 9 import android.view.Men

淘宝-保证金缴纳的类目及对应金额(2017.3.25)

今天在上架商品,突然提示保证金1万,才能上架商品.请补交保证金,吓了宝宝一跳. 宝宝一个月才几十元的收入,交1万,逼死宝宝啊.  仔细查查资料才知道.消保的基础保证金是1000元保证金,特殊才是更高. 保证金缴纳的类目及对应金额 [原文](https://service.taobao.com/support/seller/knowledge-13123494.htm) 亲,以下各类目需要缴纳相应的保证金哦,具体金额可以参考以下的表格 类目 保证金金额 电动车/配件/交通工具>>电动车整车>

Android Learning:多线程与异步消息处理机制

在最近学习Android项目源码的过程中,遇到了很多多线程以及异步消息处理的机制.由于之前对这块的知识只是浅尝辄止,并没有系统的理解.但是工程中反复出现让我意识到这个知识的重要性.所以我整理出这篇博客,主要介绍了线程和异步处理机制的意义和用法,目的在于帮助初学者能够加深对异步消息处理机制的理解,在实际Android工程中能够更多地使用AsyncTask工具类在子线程中进行UI更新. 一.Android当中的多线程[1] 在Android当中,当一个应用程序的组件启动的时候,并且没有其他的应用程序