tablelayout+dreamlayout+Xlistview+lunbo

//gson,1.93

//activity_main

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.monilianxi.MainActivity">

    <RelativeLayout
        android:layout_width="200dp"
        android:layout_height="match_parent"
        android:layout_gravity="left"
        android:background="#3A3A3A"
        android:choiceMode="singleChoice">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="这是侧滑栏"
            android:textColor="#CC0000"
            android:textSize="20sp" />

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RadioGroup
            android:id="@+id/main_rg"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_alignParentBottom="true"
            android:gravity="center"
            android:orientation="horizontal">

            <RadioButton
                android:id="@+id/main_rb_01"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:button="@null"
                android:checked="true"
                android:gravity="center"
                android:text="首页" />

            <RadioButton
                android:id="@+id/main_rb_02"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:button="@null"
                android:gravity="center"
                android:text="发现" />

            <RadioButton
                android:id="@+id/main_rb_03"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:button="@null"
                android:gravity="center"
                android:text="下载" />

            <RadioButton
                android:id="@+id/main_rb_04"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:button="@null"
                android:gravity="center"
                android:text="我的" />

        </RadioGroup>

        <FrameLayout
            android:id="@+id/main_fro"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@id/main_rg"></FrameLayout>
    </RelativeLayout>


</android.support.v4.widget.DrawerLayout>

//shouye

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.design.widget.TabLayout
        android:id="@+id/shouye_tas"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        app:tabGravity="center"
        app:tabIndicatorColor="@color/colorDccent"
        app:tabMode="fixed"
        app:tabSelectedTextColor="@color/colorDccent"
        app:tabTextColor="@color/colorCccent"></android.support.design.widget.TabLayout>

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <android.support.v4.view.ViewPager
            android:id="@+id/vp_01"
            android:layout_width="match_parent"
            android:layout_height="210dp"></android.support.v4.view.ViewPager>

        <!--android:layout_alignBottom: 控件的下边对齐-->
        <LinearLayout
            android:id="@+id/lin_bottom"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/vp_01"
            android:layout_marginBottom="7dp"
            android:gravity="center"
            android:orientation="horizontal"></LinearLayout>

    </RelativeLayout>


    <android.support.v4.view.ViewPager
        android:id="@+id/shouye_vp"
        android:layout_width="match_parent"
        android:layout_height="405dp"
        android:layout_below="@+id/shouye_tas"></android.support.v4.view.ViewPager>

</LinearLayout>
//faxian

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

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="发现页面"
        android:textColor="#f00" />

</LinearLayout>
//content

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

    <com.bawei.wzq.wzlibrary.view.XListView
        android:id="@+id/xlv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></com.bawei.wzq.wzlibrary.view.XListView>

</LinearLayout>
//list_item

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

    <com.bawei.wzq.wzlibrary.view.XListView
        android:id="@+id/xlv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></com.bawei.wzq.wzlibrary.view.XListView>

</LinearLayout>
//item_layout

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

    <ImageView
        android:id="@+id/image_view"
        android:layout_width="100dp"
        android:layout_height="100dp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:orientation="vertical">

        <TextView
            android:id="@+id/text_title"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center"
            android:textSize="18sp" />

        <TextView
            android:id="@+id/text_url"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center"
            android:textSize="12sp" />

    </LinearLayout>


</LinearLayout>
//清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.monilianxi">

    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:name=".App"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
//Main_activiry

package com.example.monilianxi;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.RadioGroup;

import com.example.monilianxi.Frag.FaxianFragment;
import com.example.monilianxi.Frag.ShouyeFragment;
import com.example.monilianxi.Frag.WodeFragment;
import com.example.monilianxi.Frag.XiazaiFragment;

public class MainActivity extends AppCompatActivity {

    private RadioGroup main_rg;
    private FrameLayout main_fro;
    private Button btn1, btn2, btn3, btn4;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        main_rg = (RadioGroup) findViewById(R.id.main_rg);
        main_fro = (FrameLayout) findViewById(R.id.main_fro);
        btn1 = (Button) findViewById(R.id.main_rb_01);
        btn2 = (Button) findViewById(R.id.main_rb_02);
        btn3 = (Button) findViewById(R.id.main_rb_03);
        btn4 = (Button) findViewById(R.id.main_rb_04);
        btn1.setTextColor(Color.RED);
        btn2.setTextColor(Color.BLACK);
        btn3.setTextColor(Color.BLACK);
        btn4.setTextColor(Color.BLACK);
        main_rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                switch (checkedId) {
                    case R.id.main_rb_01:
                        addFragment(new ShouyeFragment());
                        btn1.setTextColor(Color.RED);
                        btn2.setTextColor(Color.BLACK);
                        btn3.setTextColor(Color.BLACK);
                        btn4.setTextColor(Color.BLACK);
                        break;
                    case R.id.main_rb_02:
                        addFragment(new FaxianFragment());
                        btn1.setTextColor(Color.BLACK);
                        btn2.setTextColor(Color.RED);
                        btn3.setTextColor(Color.BLACK);
                        btn4.setTextColor(Color.BLACK);
                        break;
                    case R.id.main_rb_03:
                        addFragment(new XiazaiFragment());
                        btn1.setTextColor(Color.BLACK);
                        btn2.setTextColor(Color.BLACK);
                        btn3.setTextColor(Color.RED);
                        btn4.setTextColor(Color.BLACK);
                        break;
                    case R.id.main_rb_04:
                        addFragment(new WodeFragment());
                        btn1.setTextColor(Color.BLACK);
                        btn2.setTextColor(Color.BLACK);
                        btn3.setTextColor(Color.BLACK);
                        btn4.setTextColor(Color.RED);
                        break;
                }
            }
        });
        //添加默认进去时候的页面
        addFragment(new ShouyeFragment());

    }

    public void addFragment(Fragment fragment) {
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = supportFragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.main_fro, fragment);
        fragmentTransaction.commit();

    }
}
//

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值