美文网首页
问卷调查Demo

问卷调查Demo

作者: it奔跑在路上 | 来源:发表于2018-10-26 11:28 被阅读0次
效果图.gif
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#DFE6E0"
                android:orientation="vertical">

    <RelativeLayout
        android:background="#fff"
        android:id="@+id/rl_survey"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="测评"
            android:textColor="@android:color/black"
            android:textSize="20sp"/>
    </RelativeLayout>

    <LinearLayout
        android:layout_below="@id/rl_survey"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:id="@+id/title"
            android:textSize="20sp"
            android:layout_margin="10dp"
            android:textColor="#000"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="我是标题"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#fff"
            android:orientation="vertical"
            android:padding="10dp">

            <LinearLayout
                android:id="@+id/check_item1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:padding="10dp">

                <ImageView
                    android:id="@+id/check_image1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/button_white"/>

                <TextView
                    android:id="@+id/check_text1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="我是文本"/>

            </LinearLayout>

            <LinearLayout
                android:id="@+id/check_item2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:padding="10dp">

                <ImageView
                    android:id="@+id/check_image2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/button_white"/>

                <TextView
                    android:id="@+id/check_text2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="我是文本"/>

            </LinearLayout>


            <LinearLayout
                android:id="@+id/check_item3"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:padding="10dp">

                <ImageView
                    android:id="@+id/check_image3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/button_white"/>

                <TextView
                    android:id="@+id/check_text3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="我是文本"/>

            </LinearLayout>

            <LinearLayout
                android:id="@+id/check_item4"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:padding="10dp">

                <ImageView
                    android:id="@+id/check_image4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/button_white"/>

                <TextView
                    android:id="@+id/check_text4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="我是文本"/>
            </LinearLayout>
        </LinearLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/pre"
                android:padding="10dp"
                android:textColor="#2F70C1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="上一步"/>

            <TextView
                android:id="@+id/tv_page"
                android:padding="10dp"
                android:layout_centerInParent="true"
                android:layout_width="wrap_content"
                android:text="1/10"
                android:layout_height="wrap_content"/>

        </RelativeLayout>
    </LinearLayout>

    <Button
        android:id="@+id/submit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerInParent="true"
        android:text="提交问卷"
        android:layout_marginBottom="20dp"
        android:textColor="@android:color/white"
        android:visibility="invisible"
        android:background="@drawable/survey_commit"/>

</RelativeLayout>
/**
 * Created by zhangyapeng on 2018/10/26.
 */
class SurveyBean {
    private String title;
    private String[] sel;

    public SurveyBean(String title, String[] sel) {
        this.title = title;
        this.sel = sel;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String[] getSel() {
        return sel;
    }

    public void setSel(String[] sel) {
        this.sel = sel;
    }
}
public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    @BindView(R.id.rl_survey)
    RelativeLayout mRlSurvey;
    @BindView(R.id.title)
    TextView       mTitle;
    @BindView(R.id.check_image1)
    ImageView      mCheckImage1;
    @BindView(R.id.check_text1)
    TextView       mCheckText1;
    @BindView(R.id.check_item1)
    LinearLayout   mCheckItem1;
    @BindView(R.id.check_image2)
    ImageView      mCheckImage2;
    @BindView(R.id.check_text2)
    TextView       mCheckText2;
    @BindView(R.id.check_item2)
    LinearLayout   mCheckItem2;
    @BindView(R.id.check_image3)
    ImageView      mCheckImage3;
    @BindView(R.id.check_text3)
    TextView       mCheckText3;
    @BindView(R.id.check_item3)
    LinearLayout   mCheckItem3;
    @BindView(R.id.check_image4)
    ImageView      mCheckImage4;
    @BindView(R.id.check_text4)
    TextView       mCheckText4;
    @BindView(R.id.check_item4)
    LinearLayout   mCheckItem4;
    @BindView(R.id.pre)
    TextView       mPre;
    @BindView(R.id.tv_page)
    TextView       mTvPage;
    @BindView(R.id.submit)
    Button         mSubmit;


    
//     设置初始位置,获取第一条数据
    public static int possition = 0;

//    存储数据的集合
    private List<SurveyBean> beanAar = new ArrayList<>();

//    记录分数
    private int[] checkPossition = new int[]{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};

//    4张图片
    private ImageView[] mImageViews;

    private Handler mHandler = new Handler();

//    计算总分数
    private int score;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ButterKnife.bind(this);

        mImageViews = new ImageView[]{mCheckImage1, mCheckImage2, mCheckImage3, mCheckImage4};

        mCheckItem1.setOnClickListener(this);
        mCheckItem2.setOnClickListener(this);
        mCheckItem3.setOnClickListener(this);
        mCheckItem4.setOnClickListener(this);
        mPre.setOnClickListener(this);
        mSubmit.setOnClickListener(this);


        possition = 0;
        init();
        setDatas();

    }

    private void setDatas() {
        mTitle.setText(beanAar.get(possition).getTitle());
        mCheckText1.setText(beanAar.get(possition).getSel()[0]);
        mCheckText2.setText(beanAar.get(possition).getSel()[1]);
        mCheckText3.setText(beanAar.get(possition).getSel()[2]);
        mCheckText4.setText(beanAar.get(possition).getSel()[3]);

        mTvPage.setText(possition + 1 + "/10");
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.check_item1:
                checkPossition[possition] = 0;
                hide(0);
                next();

                break;
            case R.id.check_item2:
                checkPossition[possition] = 1;
                hide(1);
                next();

                break;
            case R.id.check_item3:
                checkPossition[possition] = 2;
                hide(2);
                next();

                break;
            case R.id.check_item4:
                checkPossition[possition] = 3;
                hide(3);
                next();

                break;

            case R.id.pre:
                pre();
                break;

            case R.id.submit:
                Log.v("666", score+"");
                Toast.makeText(MainActivity.this, "score" + score, Toast.LENGTH_SHORT).show();
                break;
            default:
                break;
        }
    }

    private void next() {
        possition += 1;

        if (possition > 9) {
            possition = 9;
            addScore();
            mSubmit.setVisibility(View.VISIBLE);

            return;
        }

        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                hide();
                setDatas();
            }
        }, 300);
    }

    /**
     * 上一步
     */
    private void pre() {
        possition -= 1;
        if (possition < 0) {
            possition = 0;
        }
        if (possition < 9) {
            mSubmit.setVisibility(View.INVISIBLE);
        }
        hide(checkPossition[possition]);
        setDatas();
    }

    private void addScore() {
        for (int i = 0; i < checkPossition.length; i++) {
            if (checkPossition[i] == -1) {
                score = 0;
                return;
            }
        }

        for (int i = 0; i < checkPossition.length; i++) {
            switch (checkPossition[i]) {
                case 0:
                    score += 10;
                    break;
                case 1:
                    score += 8;
                    break;
                case 2:
                    score += 6;
                    break;
                case 3:
                    score += 3;
                    break;

                default:
                    break;
            }
        }
    }

    private void hide(int i) {
        for (int i1 = 0; i1 < mImageViews.length; i1++) {
            if (i1 == i) {
                mImageViews[i1].setImageResource(R.drawable.button_orange_1);
            } else {
                mImageViews[i1].setImageResource(R.drawable.button_white);
            }
        }
    }

    private void hide() {
        for (int i1 = 0; i1 < mImageViews.length; i1++) {
            mImageViews[i1].setImageResource(R.drawable.button_white);
        }
    }

    public void init() {
        beanAar.add(new SurveyBean("1、您的年龄:", new String[]{"18--30岁", "31-45岁", "46-55岁", "55岁以上"}));
        beanAar.add(new SurveyBean("2、您的身体健康状况:", new String[]{"非常好", "好", "一般", "差"}));
        beanAar.add(new SurveyBean("3、您的投资年限", new String[]{"10年以上", "5-10年", "1-5年", "1年内"}));
        beanAar.add(new SurveyBean("4、您的投资经验可以被概括为:", new String[]{"丰富:是一位积极和有经验的证券投资者,并倾向于自己作出投资决定", "一般:具有一定的证券投资经验,需要进一步的指导", "有限:有过购买国债,货币型基金等保本型金融产品投资经验", "无:除银行活期和投定期储蓄存款外,基本没有其他资经验"}));
        beanAar.add(new SurveyBean("5、您曾经或正在做的投资产品(若有多项请选风险最大的一项):", new String[]{"期货、权证", "股票", "债券、基金", "无"}));
        beanAar.add(new SurveyBean("6、今后5年内您的预期收入:", new String[]{"预期收入将逐渐增加", "预期收入将保持稳定", "预期收入将不断减少", "无"}));
        beanAar.add(new SurveyBean("7、以下哪项描述最符合您的投资态度?", new String[]{"希望赚取高回报,愿意为此承担较大本金损失", "寻求资金的较高收益和成长性,愿意为此承担有限本金损失", "保守投资,不希望本金损失,愿意承担一定幅度的收益波动", "厌恶风险,不希望本金损失,希望获得稳定回报"}));
        beanAar.add(new SurveyBean("8、您用于投资的资金在您的总资产中占比大致是多少(除自用和经营性财产外)?", new String[]{"大于50%", "30%~50%", "10%~30%", "小于10%"}));
        beanAar.add(new SurveyBean("9、您在投资中能够接受的最大本金损失大致是多少?", new String[]{"最大本金亏损50%以上", "最大本金亏损20%~50%", "最大本金亏损5%~20%", "最大本金亏损5%以内"}));
        beanAar.add(new SurveyBean("10.您的投资目的是?", new String[]{"关心长期的高回报,能够接受短期的资产价值波动", "倾向长期的成长,较少关心短期的回报以及波动", "希望投资能获得一定的增值,同时获得波动适度的年回报", "只想确保资产的安全性,同时希望能够得到固定的收益"}));
    }
}
button_orange_1.png button_white.png
survey_commit.jpg

相关文章

  • 问卷调查Demo

  • 谋定而后动——问卷设计

    兵无常势,因地制宜——问卷调查只是方法 为什么做问卷调查? 这是一个很值得思考的问题,问卷调查毕竟只是万千用户研究...

  • 单人可做的CPA网赚平台,你知多少

    1.问卷调查类:做问卷调查,平均一份问卷在0.5到10元不等。完成问卷调查获得积分,由积分兑换现金。 收奖网:平均...

  • 小科助手-意见反馈

    问卷调查 现在还没有可用的问卷调查呢~~ 意见反馈 小科助手-意见反馈

  • 如何分析用户满意度?这4种常用满意度分析模型,一定要学会

    说到问卷调查,满意度调查算是众多问卷调查类型中应用最广泛的。不论是大小企业,或是政府、机构都可以通过满意度问卷调查...

  • 170809 文献笔记_辛平. 对外汉语写作课教学的验证性研究.

    摘要: 研究方法:问卷调查+文本分析 (1)问卷调查。主观评估三点: 1)写作课教学方...

  • 问卷调查

    对家长: 您对您的孩子学习成绩关心吗?关心的程度是? 您的孩子有上培训班吗?上什么培训班? 是这样的,我们打算和x...

  • 问卷调查

    关于课程开设和人才培养你有什么建议,? 就当前而言,课程的开设我不多做建议,毕竟如今我对行业也不是很了解,知识欠缺...

  • 问卷调查

    1v1调查:适用于发散型思维,可用于问题的探讨! 调查问卷:主要用于查看数据的趋势,标准化问题!

  • 问卷调查

    今天统计学老师让我们做个问卷调查,要纸质版的,明天需要录入数据,所以今天大家都在互相填这个问卷调查。填出了许多情绪...

网友评论

      本文标题:问卷调查Demo

      本文链接:https://www.haomeiwen.com/subject/aujktqtx.html