RadioGroup布局,无限轮播,二维码扫描

//图片需要从drawable中获取

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@mipmap/shouye" android:state_checked="false"/>
    <item android:drawable="@mipmap/shouye02" android:state_checked="true"/>


</selector>

//xml布局,底部导航栏

<?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"
    >
    <FrameLayout
        android:id="@+id/frame"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>
    <RadioGroup
        android:layout_width="match_parent"
        android:layout_height="85dp"
        android:orientation="horizontal">
        <RadioButton
            android:layout_width="0dp"
            android:layout_weight="1"
            android:gravity="center"
            android:layout_height="85dp"
            android:button="@null"
            android:background="@drawable/shouye"
            android:checked="true"
            android:id="@+id/shouye"/>
        <RadioButton
            android:layout_width="0dp"
            android:layout_weight="1"
            android:gravity="center"
            android:layout_height="85dp"
            android:button="@null"
            android:background="@drawable/weitao"
            android:id="@+id/weitao"/>
        <RadioButton
            android:layout_width="0dp"
            android:layout_weight="1"
            android:gravity="center"
            android:layout_height="85dp"
            android:button="@null"
            android:background="@drawable/xiaoxi"
            android:id="@+id/xiaoxi"/>
        <RadioButton
            android:layout_width="0dp"
            android:layout_weight="1"
            android:gravity="center"
            android:layout_height="85dp"
            android:button="@null"
            android:background="@drawable/gouwuche"
            android:id="@+id/gouwuche"/>
        <RadioButton
            android:layout_width="0dp"
            android:layout_weight="1"
            android:gravity="center"
            android:layout_height="85dp"
            android:button="@null"
            android:background="@drawable/wodetaobao"
            android:id="@+id/wodetaobao"/>
    </RadioGroup>



</LinearLayout>
//主方法,其中自带二维码以及轮播
//二维码导入依赖放入
dependencies{
compile 'com.github.open-android:Zxing:v1.0.3'
}

package com.example.jd.fragment;

import android.content.Context;
import android.content.Intent;
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 android.widget.ImageView;

import com.example.jd.MyBanner;
import com.example.jd.R;
import com.google.zxing.activity.CaptureActivity;
import com.youth.banner.Banner;

import java.util.ArrayList;

/**
 * Created by 额头发 on 2017/10/10.
 */

public class Fragment_shouye extends Fragment {
    private Banner banner;
    private String image1 = "http://pic2.ooopic.com/11/77/39/80bOOOPICfa_1024.jpg";
    private String image2 = "http://pic.qiantucdn.com/58pic/18/48/22/5627b9b5b48b3_1024.jpg";
    private String image3 = "http://pic2.ooopic.com/11/79/05/08bOOOPICe4_1024.jpg";
    private String image4 = "http://pic.qiantucdn.com/58pic/16/76/88/91N58PICc5P_1024.jpg!/fw/780/watermark/url/L3dhdGVybWFyay12MS4zLnBuZw==/align/center";
    private String image5 = "http://pic.58pic.com/58pic/16/93/40/65E58PICnVz_1024.jpg";
    private String image6 = "http://pic41.nipic.com/20140506/18544347_111553662000_2.jpg";
    private String image7 = "http://pic.58pic.com/58pic/13/57/21/12y58PIC8sc_1024.jpg";
    private String image8 = "http://pic.58pic.com/58pic/17/30/04/56u58PICfb9_1024.jpg";
    private ArrayList<String> list;
    private ImageView zhu_saoma;
    private ImageView zhu_huiyuanma;
    private final static int REQ_CODE = 1028;
    private View view;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.shouye, container, false);

        initView();

        //Banner轮播
        banner = (Banner) view.findViewById(R.id.banner);
        banner.setImageLoader(new MyBanner());

        list = new ArrayList<>();
        list.add(image1);
        list.add(image2);
        list.add(image3);
        list.add(image4);
        list.add(image5);
        list.add(image6);
        list.add(image7);
        list.add(image8);
        banner.setImages(list);
        banner.start();

        return view;

    }
    private void initView() {
        zhu_saoma = (ImageView) view.findViewById(R.id.zhu_saoma);
        zhu_huiyuanma = (ImageView) view.findViewById(R.id.zhu_huiyuanma);
        //二维码扫描
        zhu_saoma.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), CaptureActivity.class);
                startActivityForResult(intent, REQ_CODE);
            }
        });


    }



}

« »

发表评论

电子邮件地址不会被公开。 必填项已用*标注

昵称 *