签到界面总结

实现手机签到页面

package com.lechuang.youleduo.view.activity;

import android.content.Context;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.lechuang.youleduo.R;


/**
 * Created by zhf on 2017/8/18.
 * 【签到】
 */
public class SigneActivity extends AppCompatActivity implements View.OnClickListener{
    private Context mContext = SigneActivity.this;
    private String[] days = {"1天", "2天", "3天", "4天", "5天", "6天", "7天"};
    private GridView gv_days;
    private Button btn_sign;
    private ColorStateList redColors;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setGravity(Gravity.CENTER);
        setContentView(R.layout.activity_signe);
     
        initView();
    }

    public void initView() {
        gv_days = (GridView) findViewById(R.id.gv_days);
        redColors = ColorStateList.valueOf(0xfffe738d);
        btn_sign = (Button) findViewById(R.id.btn_sign);
        btn_sign.setOnClickListener(this);

    }

    //点击签到
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_sign:
                if (Utils.isNetworkAvailable(mContext)) {
                    signSuccess();
                } else {
                   //没有网络的情况
                }
                break;
            case R.id.iv_dismiss:

                finish();
                break;
        }
    }
/**
 *  @author li
 *  邮箱:[email protected]
 *  @time 2017/9/19  18:28
 *  @describe 请求网络,查看签到信息
 */
    private void signSuccess() {
     
    }

  /**
   *  @author li
   *  邮箱:[email protected]
   *  @time 2017/9/19  18:28
   *  @describe 适配数据
   */
    private void sign() {
        
    }

    /**
     * 天数的适配器
     */
    class SingeAdapter extends BaseAdapter {
        private int index;
        private int images[] = {R.drawable.round_r, R.drawable.round};

        public SingeAdapter(int index) {
            this.index = index;
        }

        @Override
        public int getCount() {
            return days.length;
        }

        @Override
        public Object getItem(int position) {
            return days[position];
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            MyTag mt = null;
            if (convertView == null) {
                mt = new MyTag();
                convertView = LayoutInflater.from(mContext).inflate(R.layout.item_signin_days, null);
                mt.tv_days = (TextView) convertView.findViewById(R.id.tv_days);
                mt.tv_score = (TextView) convertView.findViewById(R.id.tv_score);
                mt.iv_round = (ImageView) convertView.findViewById(R.id.iv_round);
                convertView.setTag(mt);
            } else {
                mt = (MyTag) convertView.getTag();
            }
            
            notifyDataSetChanged();
            return convertView;
        }
    }

    /**
     * viewHolder类
     */
    class MyTag {
        private TextView tv_days, tv_score;//连续签到天数,积分
        private ImageView iv_round;
    }
}

布局文件:

签到界面总结_第1张图片



实现签到页面布局

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

            android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:background="@drawable/bg_corners5_solid_white"
        android:orientation="vertical">
                    android:layout_width="wrap_content"
            android:layout_height="wrap_content">

                            android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/qiandao_beijing"/>

                            android:id="@+id/iv_dismiss"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="top|end"
                android:layout_marginTop="10dp"
                android:layout_marginRight="10dp"
                android:onClick="finish"
                android:src="@drawable/close"/>

        

                    android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="每日签到送积分"
            android:textSize="12sp"
            android:textColor="@color/black"
            android:layout_marginTop="26dp" />

                    android:id="@+id/tv_signin"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="9dp"
            android:text="连续签到满0天,奖励翻倍哦~"
            android:textSize="12sp"
            android:textColor="@color/black"/>

                    android:id="@+id/gv_days"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="25dp"
            android:horizontalSpacing="0dp"
            android:numColumns="7"
            android:listSelector="@color/transparent" />

        


你可能感兴趣的:(签到界面总结)