andriod——Retrofit+Fresco+MVP+Fragment

来源:互联网 发布:php过滤微信表情符号 编辑:程序博客网 时间:2024/05/22 01:56

导依赖包:
compile 'com.jakewharton:butterknife:8.5.1'    compile 'com.hjm:BottomTabBar:1.1.1'

fragment——fragment01
package com.example.newfragment.fragment;import android.os.Bundle;import android.support.annotation.Nullable;import android.support.v4.app.Fragment;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import com.example.newfragment.R;/** * Created by Administrator on 2017/12/2. */public class fragment01 extends Fragment {    @Nullable    @Override    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {        View view=View.inflate(getActivity(),R.layout.fragment01,null);        return view;    }}

MainActivity
package com.example.newfragment;import android.graphics.Color;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import com.example.newfragment.fragment.fragment01;import com.example.newfragment.fragment.fragment02;import com.example.newfragment.fragment.fragment03;import com.example.newfragment.fragment.fragment04;import com.hjm.bottomtabbar.BottomTabBar;public class MainActivity extends AppCompatActivity {    private BottomTabBar mb;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        mb=(BottomTabBar)findViewById(R.id.bottom_tab_bar);        mb.init(getSupportFragmentManager())                .setImgSize(0,0)                .setFontSize(10)                .setTabPadding(4,6,10)                .setChangeColor(Color.RED,Color.DKGRAY)                .addTabItem("首页",R.drawable.ic_launcher_round, fragment01.class)                .addTabItem("分类",R.drawable.ic_launcher_round, fragment02.class)                .addTabItem("购物车",R.drawable.ic_launcher_round, fragment03.class)                .addTabItem("我的",R.drawable.ic_launcher_round, fragment04.class)                .isShowDivider(false)                .setOnTabChangeListener(new BottomTabBar.OnTabChangeListener() {                    @Override                    public void onTabChange(int position, String name) {                    }                });    }}

activity_main.xml
<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="com.example.newfragment.MainActivity">    <com.hjm.bottomtabbar.BottomTabBar        android:id="@+id/bottom_tab_bar"        android:layout_width="match_parent"        android:layout_height="match_parent"        >    </com.hjm.bottomtabbar.BottomTabBar></android.support.constraint.ConstraintLayout>

fragment01.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical"></LinearLayout>





原创粉丝点击