zoukankan      html  css  js  c++  java
  • 【学习笔记】Fragment

    Create a Fragment Class:继承Fragment类

    import android.os.Bundle;
    import android.support.v4.app.Fragment;
    import android.view.LayoutInflater;
    import android.view.ViewGroup;
    
    public class ArticleFragment extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.article_view, container, false);
        }
    

    }

    Add a Fragment to an Activity using XML
    步骤一:编写xml文件 res/layout-large/news_articles.xml

    <fragment android:name="com.example.android.fragments.HeadlinesFragment"
              android:id="@+id/headlines_fragment"
              android:layout_weight="1"
              android:layout_width="0dp"
              android:layout_height="match_parent" />
    
    <fragment android:name="com.example.android.fragments.ArticleFragment"
              android:id="@+id/article_fragment"
              android:layout_weight="2"
              android:layout_width="0dp"
              android:layout_height="match_parent" />
    

    步骤二:把xml放到Activity中

    import android.os.Bundle;
    import android.support.v4.app.FragmentActivity;
    
    public class MainActivity extends FragmentActivity {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.news_articles);
        }
    }
  • 相关阅读:
    FDR校正
    PHP base64 编码转化图片并进行指定路径的保存和上传处理(转自https://cloud.tencent.com/developer/article/1333877)
    google网页评测工具
    链接类型:预加载
    鼠标经过时显示、隐藏提示
    thinkphp5导入excel数据
    JS消息窗口滚动到底部
    datatable分页使用箭头
    Mysql基础
    php-MD5/sha1
  • 原文地址:https://www.cnblogs.com/muyuetiankong/p/4448418.html
Copyright © 2011-2022 走看看