安卓移动-作业5

实验报告

1 实验目的 (Experiment Purpose)

Implement teaching materials in experiment 2.

2 实验环境 (Experiment Environment)

software: java version “18.0.2”
Android Studio 2021.2.1 Patch 2
Operating system:Window 10

3 实验内容 (Experiment content)

3.1 Experimental data

Set the string in Android/app/res/layout/value/strings.xml.
在 Android/app/res/layout/value/strings.xml中制定字符串。

<resources>
    <string name="app_name">Experiment2</string>
    <string name="account">账号:</string>
    <string name="password">密码:</string>
    <string name="submit">提交答案</string>
    <string name="input">请输入答案</string>
    <string name="question">问题</string>
    <string name="option">选项</string>
</resources>

Set the images in Android/app/res/drawable.
在 Android/app/res/drawable中放置图片。

3.2 Experimental process

3.2.1 Layout

Set the layout of log-in page in
Android/app/res/layout/activity_login.xml.
在 Android/app/res/layout/activity_login.xml中设定登录页面的布局。

Set the layout of quiz in Android/app/res/layout.
在 Android/app/res/layout中设定问题的布局。

3.2.2 Activity

LoginActivity
Set a listener for the “Login” button to jump to the “Question navigation” page if the button is clicked.
为“登陆”按钮设置监听器,若按钮被点击,则跳转到“问题导航”页面。

ExamType
Before introducing the issue navigation screen, let’s first introduce the ExamType class.
在介绍问题导航界面之前,首先介绍一下ExamType类。

public class ExamType 
{
    String type;
    int imageID;
}

数据

"单选题"+ R.drawable.ic_multichoice
"判断题"+ R.drawable.ic_trueorfalse
"多选题"+ R.drawable.ic_blankfilling
"填空题"+ R.drawable.ic_correction
"简答题"+ R.drawable.ic_shortanswer

ExamTypesActivity

  1. Get all the data for the issue navigation page, i.e. ExamTypes.
    获得问题导航页面的所有数据,即ExamTypes。

    ExamTypes examTypes = new ExamTypes();
    List<ExamTypes.ExamType> examTypeList = examTypes.getExamTypeList();
    
  2. Get RecylerView
    获得RecylerView

    RecyclerView recyclerView = findViewById(R.id.types_recycler_view);
    
  3. Set this RecylerView to a linear layout
    将该RecylerView设置为线性布局

    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(layoutManager);
    
  4. Define the adapter adapter and set it up for RecylerView.
    定义适配器adapter,并为RecylerView设置该适配器。

    ExamTypesAdapter adapter = new ExamTypesAdapter(examTypeList, ExamTypesActivity.this);
    recyclerView.setAdapter(adapter);
    

If you click on “Type of question”, you will be redirected to the corresponding question page.
If you click on the “Topic icon”, the message “Press on the image: question type xxx” will be displayed.
若点击“题目类型”,则跳转到对应的题目页面。
若点击“题目图标”,则显示提示信息“按在图片上:题型xxx”。
(因篇幅问题,此处不放Adapter具体代码。)

Questions

Before introducing the Questions screen, let’s first introduce the Questions class.
在介绍问题界面之前,首先介绍一下Questions类。

class Single{
    String ask;
    String[] option;
    int answer;}	
class Judgmental {
    String ask;
    int answer;}	
class ShortAnswer{
    String ask;
    String answer;
}
class Multiples{
    String ask;
    String[] options;
    String answer;}	
class Completion{
    String ask;
    String answer;}

方法:

public ArrayList<Single> CreateSingle();	
public ArrayList<Judgmental> CreateJudgmental();	
public ArrayList<ShortAnswer> CreateShortAnswer();
public ArrayList<Multiples> CreateMultiples();	
public ArrayList<Completion> CreateCompletion();

ViewPagerActivity

  1. Get all the data for the questions page, i.e. questions.
    获得问题页面的所有数据,即questions。

    Questions questions = new Questions();
    
  2. Get the viewPager
    获得viewPager

    viewPager = findViewById(R.id.*view_pager*);
    
  3. obtain the type of question clicked on from the Question Navigation page and set the answer mechanism of the page according to the type of question.
    从"问题导航"页面获得点击的题目类型,并根据题目类型设定页面的答题机制。

    Intent intent = getIntent();
    String type = intent.getStringExtra("类型");
    

    If the type is single choice, call quiz_pager1.xml (single choice layout) and call questions.CreateSingle() to get the question, option and answer for the single choice.
    If the type is Judgmental, then call quiz_pager2.xml (Judgmental layout), call questions.CreateJudgmental() to get the question and answer for the judgment question.
    If the type is multiple choice, then call quiz_pager3.xml (multiple choice layout), call questions.CreateMultiples() to get the questions, options and answers for the multiple choice questions.
    If the type is fill-in-the-blank, call quiz_pager4.xml (the fill-in-the-blank layout) and call questions.CreateCompletion() to get the question and answer for the fill-in-the-blank question.
    If the type is short answer, then call quiz_pager5.xml (short answer layout), call questions.CreateShortAnswer() to get the short answer and answer to the single choice question.
    如果类型是单选题,则调用quiz_pager1.xml(单选题布局),调用questions.CreateSingle(),获得单选题的题目、选项与答案。
    如果类型是判断题,则调用quiz_pager2.xml(判断题布局),调用questions.CreateJudgmental()
    ,获得判断题的题目与答案。
    如果类型是多选题,则调用quiz_pager3.xml(多选题布局),调用questions.CreateMultiples()
    ,获得多选题的题目、选项与答案。
    如果类型是填空题,则调用quiz_pager4.xml(填空题布局),调用questions.CreateCompletion()
    ,获得填空题的题目与答案。
    如果类型是简答题,则调用quiz_pager5.xml(简答题布局),调用questions.CreateShortAnswer()
    ,获得单选题的简答与答案。
    (因篇幅问题,此处不放代码。)

  4. Define the adapter adapter and set this adapter for the viewPager.
    定义适配器adapter,并为viewPager设置该适配器。

    viewPager.setAdapter(pagerAdapter);
    (因篇幅问题,此处不放Adapter具体代码。)
    
3.3 Experimental results

The results display are shown as follows:
结果展示:
The following two pages show the “landing page” and the navigation
page respectively
以下两个页面分别是"登陆页面"和导航页面展示

The following 5 pages show the “Single Choice”, “Judgement”, “Multiple Choice”, “Fill in the Blanks” and “Short Answer” pages respectively.
以下5个页面分别是“单选题”,“判断题”,“多选题”,“填空题”,“简答题”的页面展示:

The following 5 pages are the way to display answers for each of the 5 types of questions (there are two ways: reminders, text boxes to display answers)

以下5个页面是分别是5种类型的题目显示答案的方式(有两种方式:提醒,文本框显示答案)

3.4 Analysis

The "Adapter " is the adapter interface that connects the back-end data to the front-end display. For the use of the RecyclerView, the Adapter is the intermediary used to map the data to the RecyclerView.
For example, the “Questions navigation page” needs to map the ExamType (data) to the elements in the recyclerView one by one.
For example, the “Questions page” needs to map the Questions (data) to the elements in the ViewPager one by one.
Adapter是连接后端数据和前端显示的适配器接口。对于RecyclerView的使用,适配器是用来把数据映射到RecyclerView上的中介。
比如问题导航页面,需要把ExamType(数据)和recyclerView中的元素一一映射。
比如问题页面,需要把Questions(数据)和ViewPager中的元素一一映射。

recyclerView

The examTypeAdapter has three main methods.
getItemCount: Gets the number of list items. In this project, this means getting the size of the examTypeList.
onCreateViewHolder: creates a view holder for the whole layout. The input parameters include the view type, which allows different layouts to be loaded depending on the view type, resulting in a list layout with a header. Used to load the layout of a RecyclerView child and then return a ViewHolder object. In this project, this means defining the ViewHolder object and implementing the page’s button listening functionality.
onBindViewHolder: Bind data for the child items. Bind the view holder of each item. In this project, i.e. corresponds the title type in the view to the image in the examType and the title icon in the view to the title type in the examType.
examTypeAdapter主要有三个方法:

  • getItemCount:获取列表项的数目。在本项目中,即获得examTypeList的size。
  • onCreateViewHolder:创建整个布局的视图持有者。输入参数中包括视图类型,可根据视图类型加载不同的布局,从而实现带头部的列表布局。用于加载 RecyclerView 子项的布局,然后返回一个 ViewHolder 对象。在本项目中,即定义ViewHolder对象和实现页面的按钮监听功能。
  • onBindViewHolder:为子项绑定数据。绑定每项的视图持有者。在本项目中,即将view中的题目类型和examType中的图片对应,将view中的题目图标与examType中的标题类型对应。

ViewPager

PagerAdapter is mainly an adapter for viewpager, which can implement the sliding effect of the control, such as the sliding effect of the issue page, which can be achieved with viewPager. The pagerAdapter contains 2 main methods. - Object instantiateItem(ViewGroup container, int position) This method is called to initialise the layout of a page to be displayed or a page that needs to be cached. In this project, this method is used to add the view subscripted as postion in the viewList to the container. - void destroyItem(ViewGroup container, int position, Object object) Called when the ViewPager needs to destroy a page, we need to remove the view corresponding to position from the container. In this project, this method is used to move the view with the subscript of postion in the viewList out of the container. PagerAdapter主要是viewpager的适配器,可以实现控件的滑动效果,比如问题页面的滑动效果,用viewPager就可以实现。 pagerAdapter主要包含2个方法: - Object instantiateItem(ViewGroup container, int position) 要显示的页面或需要缓存的页面,会调用这个方法进行布局的初始化。 在本项目中,使用这个方法将viewList中下标为postion的view加入container中。 - void destroyItem(ViewGroup container, int position, Object object) 当ViewPager需要销毁一个页面时调用,我们需要将position对应的view从container中移除。 在本项目中,使用这个方法将viewList中下标为postion的view移出container。

4 实验小结 (Summary)

My thoughts and experiences

About RecyclerView

  1. Introducing the library
  2. Adding layout files
  3. Adding the item layout file
  4. Adding the adapter
  5. Initialize the layout
    The RecyclerView uses the adapter pattern to separate the user interface display from the interaction. There are three main methods: getItemCount, onCreateViewHolder, onBindViewHolder.
关于RecyclerView
  1. 引入库
  2. 添加布局文件
  3. 添加item布局文件
  4. 添加适配器
  5. 初始化布局
    RecyclerView使用适配器模式,将用户界面展示与交互分离。主要有三个方法:getItemCount、onCreateViewHolder、onBindViewHolder。
About ViewPager
  1. introduce the library
  2. add the layout file (you can directly new PagerAdapter or create a subclass)
  3. Add an adapter
    ViewPager uses the adapter pattern to separate user interface presentation from interaction. There are four main methods: instantiateItem, destroyItem, isViewFromObject, getItemPosition (you can add others according to your needs, for example, the methods in this project are: isViewFromObject, getCount, destroyItem, instantiateItem, getPage. instantiateItem, getPageTitle).
关于ViewPager
  1. 引入库
  2. 添加布局文件(可直接new PagerAdapter,也可以创建子类)
  3. 添加适配器
    ViewPager使用适配器模式,将用户界面展示与交互分离。主要有四个方法:instantiateItem、destroyItem、isViewFromObject、getItemPosition。(可根据需求添加其他的,如本项目方法有:isViewFromObject、getCount、destroyItem、instantiateItem、getPageTitle)。

5 附录 (Appendix)

ExamTypes
package com.example.experiment2;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;

import java.util.ArrayList;
import java.util.Objects;

public class ViewPagerActivity extends AppCompatActivity
{

    private ViewPager viewPager;  //对应的viewPager
    private ArrayList<View> viewList;  //view数组
    Context mContext = this;





    PagerAdapter pagerAdapter = new PagerAdapter()
    {
        final String[] titles = new String[]{
                "No.1",
                "No.2",
                "No.3"};

        @Override
        public boolean isViewFromObject(View arg0, Object arg1)
        {
            return arg0 == arg1;
        }

        @Override
        public int getCount()
        {
            return viewList.size();
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object)
        {
            container.removeView(viewList.get(position));
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position)
        {
            container.addView(viewList.get(position));
            return viewList.get(position);
        }

        @Override
        public CharSequence getPageTitle(int position)
        {
            return titles[position];
        }
    };


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

        //整个页面分为两部分:上面一行显示第几题,下面是题目
        viewPager = findViewById(R.id.view_pager);
        viewList = new ArrayList<View>();
        LayoutInflater inflater = getLayoutInflater();

        //获得题目类型
        Intent intent = getIntent();
        String type = intent.getStringExtra("类型");

        Questions questions = new Questions();
        if (Objects.equals(type, "单选题"))
        {
            ArrayList<Questions.Single> questions1 = questions.CreateSingle();
            for (Questions.Single question : questions1)
            {
                View view = inflater.inflate(R.layout.quiz_pager1, null);
                RadioGroup radioGroup = view.findViewById(R.id.group);
                TextView ask = view.findViewById(R.id.quiz_view_1);
                RadioButton a = view.findViewById(R.id.A);
                RadioButton b = view.findViewById(R.id.B);
                RadioButton c = view.findViewById(R.id.C);
                RadioButton d = view.findViewById(R.id.D);

                ask.setText(question.ask);
                a.setText(question.option[0]);
                b.setText(question.option[1]);
                c.setText(question.option[2]);
                d.setText(question.option[3]);
                radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
                {
                    @Override
                    public void onCheckedChanged(RadioGroup radioGroup, int checkId)
                    {
                        if (checkId == radioGroup.getChildAt(question.answer).getId())
                            Toast.makeText(mContext, "答案正确", Toast.LENGTH_SHORT).show();
                        else
                            Toast.makeText(mContext, "答案错误", Toast.LENGTH_SHORT).show();
                    }
                });
                viewList.add(view);
            }
        } else if (Objects.equals(type, "判断题"))
        {
            ArrayList<Questions.Judgmental> questions2 = questions.CreateJudgmental();
            for (Questions.Judgmental question : questions2)
            {
                View view = inflater.inflate(R.layout.quiz_pager2, null);
                TextView ask = view.findViewById(R.id.quiz_view_1);
                ask.setText(question.ask);
                RadioGroup radioGroup = view.findViewById(R.id.group);
                radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
                {
                    @Override
                    public void onCheckedChanged(RadioGroup radioGroup, int checkId)
                    {
                        if (checkId == radioGroup.getChildAt(question.answer).getId())
                            Toast.makeText(mContext, "答案正确", Toast.LENGTH_SHORT).show();
                        else
                            Toast.makeText(mContext, "答案错误", Toast.LENGTH_SHORT).show();
                    }
                });
                viewList.add(view);
            }
        } else if (Objects.equals(type, "简答题"))
        {
            ArrayList<Questions.ShortAnswer> questions3 = questions.CreateShortAnswer();
            for (Questions.ShortAnswer question : questions3)
            {
                View view = inflater.inflate(R.layout.quiz_pager5, null);
                TextView ask = view.findViewById(R.id.quiz_view_1);
                Button submit = view.findViewById(R.id.submit);
                TextView answer = view.findViewById(R.id.ans);

                submit.setOnClickListener(new View.OnClickListener()
                {
                    @Override
                    public void onClick(View view)
                    {
                        answer.setText("参考答案:\n" + question.answer);
                    }
                });
                ask.setText(question.ask);
                viewList.add(view);
            }
        } else if (Objects.equals(type, "多选题"))
        {
            ArrayList<Questions.Multiples> questions4 = questions.CreateMultiples();
            for (Questions.Multiples question : questions4)
            {
                View view = inflater.inflate(R.layout.quiz_pager3, null);
                TextView ask = view.findViewById(R.id.quiz_view_1);
                TextView answer = view.findViewById(R.id.ans);
                Button submit = view.findViewById(R.id.submit);
                CheckBox a = view.findViewById(R.id.option1);
                CheckBox b = view.findViewById(R.id.option2);
                CheckBox c = view.findViewById(R.id.option3);
                CheckBox d = view.findViewById(R.id.option4);

                ask.setText(question.ask);
                a.setText(question.options[0]);
                b.setText(question.options[1]);
                c.setText(question.options[2]);
                d.setText(question.options[3]);
                submit.setOnClickListener(new View.OnClickListener()
                {
                    @Override
                    public void onClick(View view)
                    {
                        answer.setText("参考答案:\n" + question.answer);
                    }
                });
                viewList.add(view);
            }
        } else
        {
            ArrayList<Questions.Completion> questions5 = questions.CreateCompletion();
            for (Questions.Completion question : questions5)
            {
                View view = inflater.inflate(R.layout.quiz_pager4, null);
                TextView ask = view.findViewById(R.id.quiz_view_1);
                TextView answer = view.findViewById(R.id.ans);
                Button submit = view.findViewById(R.id.submit);

                ask.setText(question.ask);
                submit.setOnClickListener(new View.OnClickListener()
                {
                    @Override
                    public void onClick(View view)
                    {
                        answer.setText("参考答案:\n" + question.answer);
                    }
                });
                viewList.add(view);
            }
        }

        //页面适配器
        viewPager.setAdapter(pagerAdapter);

//        CircleIndicator indicator = findViewById(R.id.indicator);
//        indicator.setViewPager(viewPager);
//        pagerAdapter.registerDataSetObserver(indicator.getDataSetObserver());

//        viewPager.setPageTransformer(true, new ScalePageTransformer());
//        viewPager.setPageTransformer(true, new RotatePageTransformer());
        viewPager.setPageTransformer(true, new GalleryPageTransformer());

    }


    public class ScalePageTransformer implements ViewPager.PageTransformer
    {
        private static final float MIN_SCALE = 0.75f;

        @Override
        public void transformPage(View page, float position)
        {
            // 超出左屏幕
            //Log.d("TAG", "<"+page.hashCode()+", "+position+">");
            if (position < -1.0f)
            {
                page.setScaleX(MIN_SCALE);
                page.setScaleY(MIN_SCALE);
            } else if (position <= 0.0f)
            {
                // 向左滑动
                page.setAlpha(1.0f);
                page.setTranslationX(0.0f);
                page.setScaleX(1.0f);
                page.setScaleY(1.0f);
            } else if (position <= 1.0f)
            {
                // 向右滑动
                page.setAlpha(1.0f - position);
                page.setTranslationX(-page.getWidth() * position);
                float scale = MIN_SCALE + (1.0f - MIN_SCALE) * (1.0f - position);
                page.setScaleX(scale);
                page.setScaleY(scale);
            }
            // 超出右屏幕
            else
            {
                page.setScaleX(MIN_SCALE);
                page.setScaleY(MIN_SCALE);
            }
        }
    }

    public class RotatePageTransformer implements ViewPager.PageTransformer
    {
        private static final float MAX_ROTATION = 20.0f;

        @Override
        public void transformPage(View page, float position)
        {
            if (position < -1)
                rotate(page, -MAX_ROTATION);
            else if (position <= 1)
                rotate(page, MAX_ROTATION * position);
            else
                rotate(page, MAX_ROTATION);
        }

        private void rotate(View view, float rotation)
        {
            view.setPivotX(view.getWidth() * 0.5f);
            view.setPivotY(view.getHeight());
            view.setRotation(rotation);
        }
    }

    public class GalleryPageTransformer implements ViewPager.PageTransformer
    {
        private static final float MAX_ROTATION = 20.0f;
        private static final float MIN_SCALE = 0.75f;
        private static final float MAX_TRANSLATE = 20.0f;

        @Override
        public void transformPage(View page, float position)
        {
            if (position < -1)
            {
                page.setTranslationX(MAX_TRANSLATE);
                page.setScaleX(MIN_SCALE);
                page.setScaleY(MIN_SCALE);
                page.setRotationY(-MAX_ROTATION);
            } else if (position <= 0)
            {
                page.setTranslationX(-MAX_TRANSLATE * position);
                float scale = MIN_SCALE + (1 - MIN_SCALE) * (1.0f + position);
                page.setScaleX(scale);
                page.setScaleY(scale);
                page.setRotationY(MAX_ROTATION * position);
            } else if (position <= 1)
            {
                page.setTranslationX(-MAX_TRANSLATE * position);
                float scale = MIN_SCALE + (1 - MIN_SCALE) * (1.0f - position);
                page.setScaleX(scale);
                page.setScaleY(scale);
                page.setRotationY(MAX_ROTATION * position);
            } else
            {
                page.setTranslationX(-MAX_TRANSLATE);
                page.setScaleX(MIN_SCALE);
                page.setScaleY(MIN_SCALE);
                page.setRotationY(MAX_ROTATION);
            }
        }
    }
}
ExamTypesActivity
package com.example.experiment2;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class ExamTypesActivity extends AppCompatActivity {

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

        //数据——examTypeList:所有的[题目类型+题目图片]
        ExamTypes examTypes = new ExamTypes();
        List<ExamTypes.ExamType> examTypeList = examTypes.getExamTypeList();

        //获得RecyclerView(activity_exam_types.xml中),里面只有一个recycle
        RecyclerView recyclerView = findViewById(R.id.types_recycler_view);

        //定义线性布局,并设置为垂直布局
        //然后将RecyclerView设置为该布局
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);

        //获得ExamTypesAdapter适配器
        //然后将RecyclerView设置为该ExamTypesAdapter
        ExamTypesAdapter adapter = new ExamTypesAdapter(examTypeList, ExamTypesActivity.this);
        recyclerView.setAdapter(adapter);
    }
}

ExamTypesAdapter
package com.example.experiment2;

import android.content.Context;
import android.content.Intent;
//import android.support.v7.widget.RecyclerView;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class ExamTypesAdapter extends RecyclerView.Adapter<ExamTypesAdapter.ViewHolder>
{

    private static final String TAG = "ExamTypesAdapter";
    private Context context;

    static class ViewHolder extends RecyclerView.ViewHolder
    {
        View typeView;
        ImageView examTypeIcon;
        TextView examTypeTitle;

        public ViewHolder(View view)
        {
            super(view);
            typeView = view;
            //exam_types_item中
            examTypeIcon = view.findViewById(R.id.exam_type_icon);
            examTypeTitle = view.findViewById(R.id.exam_type_title);
        }
    }

    private List<ExamTypes.ExamType> examTypeList;

    public ExamTypesAdapter(List<ExamTypes.ExamType> examTypeList, Context ctx)
    {
        if (BuildConfig.DEBUG && examTypeList == null)
        {
            Log.d(TAG, "ExamTypesAdapter: examTypeList == null");
        }
        this.examTypeList = examTypeList;
        context = ctx;
    }

    @Override
    public int getItemCount()
    {
        return examTypeList.size();
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
    {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.exam_types_item, parent, false);

        final ViewHolder holder = new ViewHolder(view);

        // 点击题目类型,跳转到ViewPagerActivity页面
        holder.typeView.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                int position = holder.getAdapterPosition();
                ExamTypes.ExamType type = examTypeList.get(position);
                //Toast.makeText(v.getContext(), "题型:" + type.getType(), Toast.LENGTH_SHORT).show();

                Intent i = new Intent(context, ViewPagerActivity.class);
                i.putExtra("类型", type.getType());
                context.startActivity(i);
            }
        });

        //点在图片上,显示”按在图片上,题型“的提示信息
        holder.examTypeIcon.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                int position = holder.getAdapterPosition();
                ExamTypes.ExamType type = examTypeList.get(position);
                Toast.makeText(v.getContext(), "按在图片上,题型:" + type.getType(), Toast.LENGTH_SHORT).show();
            }
        });
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position)
    {
        ExamTypes.ExamType type = examTypeList.get(position);
        holder.examTypeIcon.setImageResource(type.getImageID());
        holder.examTypeTitle.setText(type.getType());
    }
}

LoginActivity
package com.example.experiment2;

import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.preference.PreferenceManager;
//import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class LoginActivity extends AppCompatActivity {
    private EditText accountEdit;
    private EditText passwordEdit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
//        TextView textView = findViewById(R.id.welcome);
//        Typeface typeFace = Typeface.createFromAsset(getAssets(),"fonts/HanYi.ttf");
//        textView.setTypeface(typeFace);


        // 测试界面登录
        TestLogin();
    }

    public void TestLogin(){
        accountEdit  = (EditText)findViewById(R.id.account);
        passwordEdit = (EditText)findViewById(R.id.password);

        Button btnLogin = (Button) findViewById(R.id.login);

        btnLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(LoginActivity.this,
                        ExamTypesActivity.class);
                startActivity(i);
            }
        });
    }
}

Questions
package com.example.experiment2;

import android.content.Intent;

import java.util.ArrayList;

public class Questions {
    ArrayList<Single>questions1;
    ArrayList<Judgmental>questions2;
    ArrayList<ShortAnswer>questions3;
    ArrayList<Multiples>questions4;
    ArrayList<Completion>questions5;


//    单选--------------------------------------------
    class Single{
        String ask;
        String[] option;
        int answer;

        Single(String ask,String[] option,int answer)
        {
            this.ask = ask;
            this.option  =option;
            this.answer = answer;
        }

        Single(String ask,int answer)
        {
            this.ask = ask;
            this.answer = answer;
        }
    }

    public ArrayList<Single> CreateSingle()
    {
        String ask1 = "应用程序层是一个核心应用程序的集合,主要包括( )。";
        String ask2 = "ADB的常见指令中“列出所有设备”的指令是( )。";
        String ask3="相对布局中,“是否跟父布局底部对齐”是属性( )。";

        String[] option1 = {"活动管理器","短信程序","音频驱动","Dalvik虚拟机"};
        String[] option2 = {"adb uninstall","adb install","adb device","adb emulator –avd"};
        String[] option3 = {"android:layout_alignBottom","android:layout_alignParentBottom","android:layout_alignBaseline","android:layout_below"};
        questions1 = new ArrayList<>();
        questions1.add(new Single(ask1, option1, 2));
        questions1.add(new Single(ask2,  option2,3));
        questions1.add(new Single(ask3,option3,  2));
        return questions1;
    }

//    判断--------------------------------------------
    class Judgmental {
        String ask;
        int answer;
        Judgmental(String ask,int answer){
            this.ask=ask;
            this.answer=answer;
        }
    }

    public ArrayList<Judgmental> CreateJudgmental()
    {
        questions2 = new ArrayList<>();
        questions2.add(new Judgmental("WCDMA是中国自己独自制定的3G标准,中国移动使用的就是这种标准( )。",2));
        questions2.add(new Judgmental("Android第1个版本Android1.1,是2008年9月发布的( )。",1));
        questions2.add(new Judgmental("AndroidManifest.xml文件是整个程序的配置文件( )。",1));
        return questions2;
    }

    //    简答--------------------------------------------
    class ShortAnswer{
        String ask;
        String answer;
        ShortAnswer(String ask,String answer)
        {
            this.ask = ask;
            this.answer =answer;
        }
    }
    public ArrayList<ShortAnswer> CreateShortAnswer()
    {
        questions3 = new ArrayList<>();
        questions3.add(new ShortAnswer("Android应用程序的四大核心组件分别是什么?","activity,service,content provider,broadcast receiver"));
        questions3.add(new ShortAnswer("Intent传递数据有两种方法是什么?","使用putExtra(),使用bundle传递数据"));
        questions3.add(new ShortAnswer("Android进程,按照优先顺序排列,分为哪几类?","Android 5个进程及重要优先级 前台进程>可见进程>服务进程>后台进程>空进程"));
        return questions3;
    }

    //    多选--------------------------------------------
    class Multiples{
        String ask;
        String[] options;
        String answer;

        Multiples(String ask,String[] options,String answer)
        {
            this.ask = ask;
            this.options=options;
            this.answer=answer;
        }
    }
    public ArrayList<Multiples> CreateMultiples()
    {
        String ask1="String,StringBuffer和StringBuilder的区别?";
        String[] options1={"String属于不可变对象,每次修改都会生成新的对象。","StringBuilder:可变对象,非多线程安全,效率高于StringBuffer","StringBuffer:可变对象,多线程安全。","效率:StringBuilder>StringBuffer>String"};
        String answer1="A,B,C,D";

        String ask2 = "java中抽象类和接口的特点?";
        String[] options2={"抽象类和接口都不能生成具体的实例。","都是作为上层使用。","抽象类可以有属性和成员方法,接口不可以。","一个类只能继承一个类,但是可以实现多个接口。"};
        String answer2 = "A,B,C,D";

        String ask3="关于多态的理解正确的是?";
        String[] options3={"多态的定义:允许不同类对同一消息做出响应。","多态是面向对象的三大特性:继承,封装和多态之一。","多态存在的条件要有继承,要有复写,父类引用指向子类对象。","java中多态的实现方式:接口实现,继承父类进行方法重写,同一个类中的方法重载。"};
        String answer3="A,B,C,D";
        questions4 = new ArrayList<>();
        questions4.add(new Multiples(ask1,options1,answer1));
        questions4.add(new Multiples(ask2,options2,answer2));
        questions4.add(new Multiples(ask3,options3,answer3));

        return questions4;
    }
    //    填空题--------------------------------------------
    class Completion{
        String ask;
        String answer;
        Completion(String ask,String answer)
        {
            this.ask=ask;
            this.answer=answer;
        }
    }
    public ArrayList<Completion> CreateCompletion()
    {
        String ask1="HashMap的特点是什么?\n1.通过________确定数组的位置。\n" + "2.找到以后,如果该位置________,则直接存放。\n" + "3.该位置有节点即位置发生冲突,遍历该节点以及后续的节点,比较key值,相等则________。";
        String answer1="键的Hash值\n无节点\n覆盖";
        String ask2="面向对象的三大特性:";
        String answer2="继承\n封装\n多态";
        String ask3="String,StringBuffer和StringBuilder的效率排序为?";
        String answer3="StringBuilder\nStringBuffer\nString";

        questions5 = new ArrayList<>();
        questions5.add(new Completion(ask1, answer1));
        questions5.add(new Completion(ask2, answer2));
        questions5.add(new Completion(ask3, answer3));
        return questions5;
    }
}

ViewPagerActivity
package com.example.experiment2;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;

import java.util.ArrayList;
import java.util.Objects;

public class ViewPagerActivity extends AppCompatActivity
{

    private ViewPager viewPager;  //对应的viewPager
    private ArrayList<View> viewList;  //view数组
    Context mContext = this;





    PagerAdapter pagerAdapter = new PagerAdapter()
    {
        final String[] titles = new String[]{
                "No.1",
                "No.2",
                "No.3"};

        @Override
        public boolean isViewFromObject(View arg0, Object arg1)
        {
            return arg0 == arg1;
        }

        @Override
        public int getCount()
        {
            return viewList.size();
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object)
        {
            container.removeView(viewList.get(position));
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position)
        {
            container.addView(viewList.get(position));
            return viewList.get(position);
        }

        @Override
        public CharSequence getPageTitle(int position)
        {
            return titles[position];
        }
    };


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

        //整个页面分为两部分:上面一行显示第几题,下面是题目
        viewPager = findViewById(R.id.view_pager);
        viewList = new ArrayList<View>();
        LayoutInflater inflater = getLayoutInflater();

        //获得题目类型
        Intent intent = getIntent();
        String type = intent.getStringExtra("类型");

        Questions questions = new Questions();
        if (Objects.equals(type, "单选题"))
        {
            ArrayList<Questions.Single> questions1 = questions.CreateSingle();
            for (Questions.Single question : questions1)
            {
                View view = inflater.inflate(R.layout.quiz_pager1, null);
                RadioGroup radioGroup = view.findViewById(R.id.group);
                TextView ask = view.findViewById(R.id.quiz_view_1);
                RadioButton a = view.findViewById(R.id.A);
                RadioButton b = view.findViewById(R.id.B);
                RadioButton c = view.findViewById(R.id.C);
                RadioButton d = view.findViewById(R.id.D);

                ask.setText(question.ask);
                a.setText(question.option[0]);
                b.setText(question.option[1]);
                c.setText(question.option[2]);
                d.setText(question.option[3]);
                radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
                {
                    @Override
                    public void onCheckedChanged(RadioGroup radioGroup, int checkId)
                    {
                        if (checkId == radioGroup.getChildAt(question.answer).getId())
                            Toast.makeText(mContext, "答案正确", Toast.LENGTH_SHORT).show();
                        else
                            Toast.makeText(mContext, "答案错误", Toast.LENGTH_SHORT).show();
                    }
                });
                viewList.add(view);
            }
        } else if (Objects.equals(type, "判断题"))
        {
            ArrayList<Questions.Judgmental> questions2 = questions.CreateJudgmental();
            for (Questions.Judgmental question : questions2)
            {
                View view = inflater.inflate(R.layout.quiz_pager2, null);
                TextView ask = view.findViewById(R.id.quiz_view_1);
                ask.setText(question.ask);
                RadioGroup radioGroup = view.findViewById(R.id.group);
                radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
                {
                    @Override
                    public void onCheckedChanged(RadioGroup radioGroup, int checkId)
                    {
                        if (checkId == radioGroup.getChildAt(question.answer).getId())
                            Toast.makeText(mContext, "答案正确", Toast.LENGTH_SHORT).show();
                        else
                            Toast.makeText(mContext, "答案错误", Toast.LENGTH_SHORT).show();
                    }
                });
                viewList.add(view);
            }
        } else if (Objects.equals(type, "简答题"))
        {
            ArrayList<Questions.ShortAnswer> questions3 = questions.CreateShortAnswer();
            for (Questions.ShortAnswer question : questions3)
            {
                View view = inflater.inflate(R.layout.quiz_pager5, null);
                TextView ask = view.findViewById(R.id.quiz_view_1);
                Button submit = view.findViewById(R.id.submit);
                TextView answer = view.findViewById(R.id.ans);

                submit.setOnClickListener(new View.OnClickListener()
                {
                    @Override
                    public void onClick(View view)
                    {
                        answer.setText("参考答案:\n" + question.answer);
                    }
                });
                ask.setText(question.ask);
                viewList.add(view);
            }
        } else if (Objects.equals(type, "多选题"))
        {
            ArrayList<Questions.Multiples> questions4 = questions.CreateMultiples();
            for (Questions.Multiples question : questions4)
            {
                View view = inflater.inflate(R.layout.quiz_pager3, null);
                TextView ask = view.findViewById(R.id.quiz_view_1);
                TextView answer = view.findViewById(R.id.ans);
                Button submit = view.findViewById(R.id.submit);
                CheckBox a = view.findViewById(R.id.option1);
                CheckBox b = view.findViewById(R.id.option2);
                CheckBox c = view.findViewById(R.id.option3);
                CheckBox d = view.findViewById(R.id.option4);

                ask.setText(question.ask);
                a.setText(question.options[0]);
                b.setText(question.options[1]);
                c.setText(question.options[2]);
                d.setText(question.options[3]);
                submit.setOnClickListener(new View.OnClickListener()
                {
                    @Override
                    public void onClick(View view)
                    {
                        answer.setText("参考答案:\n" + question.answer);
                    }
                });
                viewList.add(view);
            }
        } else
        {
            ArrayList<Questions.Completion> questions5 = questions.CreateCompletion();
            for (Questions.Completion question : questions5)
            {
                View view = inflater.inflate(R.layout.quiz_pager4, null);
                TextView ask = view.findViewById(R.id.quiz_view_1);
                TextView answer = view.findViewById(R.id.ans);
                Button submit = view.findViewById(R.id.submit);

                ask.setText(question.ask);
                submit.setOnClickListener(new View.OnClickListener()
                {
                    @Override
                    public void onClick(View view)
                    {
                        answer.setText("参考答案:\n" + question.answer);
                    }
                });
                viewList.add(view);
            }
        }

        //页面适配器
        viewPager.setAdapter(pagerAdapter);

//        CircleIndicator indicator = findViewById(R.id.indicator);
//        indicator.setViewPager(viewPager);
//        pagerAdapter.registerDataSetObserver(indicator.getDataSetObserver());

//        viewPager.setPageTransformer(true, new ScalePageTransformer());
//        viewPager.setPageTransformer(true, new RotatePageTransformer());
        viewPager.setPageTransformer(true, new GalleryPageTransformer());

    }


    public class ScalePageTransformer implements ViewPager.PageTransformer
    {
        private static final float MIN_SCALE = 0.75f;

        @Override
        public void transformPage(View page, float position)
        {
            // 超出左屏幕
            //Log.d("TAG", "<"+page.hashCode()+", "+position+">");
            if (position < -1.0f)
            {
                page.setScaleX(MIN_SCALE);
                page.setScaleY(MIN_SCALE);
            } else if (position <= 0.0f)
            {
                // 向左滑动
                page.setAlpha(1.0f);
                page.setTranslationX(0.0f);
                page.setScaleX(1.0f);
                page.setScaleY(1.0f);
            } else if (position <= 1.0f)
            {
                // 向右滑动
                page.setAlpha(1.0f - position);
                page.setTranslationX(-page.getWidth() * position);
                float scale = MIN_SCALE + (1.0f - MIN_SCALE) * (1.0f - position);
                page.setScaleX(scale);
                page.setScaleY(scale);
            }
            // 超出右屏幕
            else
            {
                page.setScaleX(MIN_SCALE);
                page.setScaleY(MIN_SCALE);
            }
        }
    }

    public class RotatePageTransformer implements ViewPager.PageTransformer
    {
        private static final float MAX_ROTATION = 20.0f;

        @Override
        public void transformPage(View page, float position)
        {
            if (position < -1)
                rotate(page, -MAX_ROTATION);
            else if (position <= 1)
                rotate(page, MAX_ROTATION * position);
            else
                rotate(page, MAX_ROTATION);
        }

        private void rotate(View view, float rotation)
        {
            view.setPivotX(view.getWidth() * 0.5f);
            view.setPivotY(view.getHeight());
            view.setRotation(rotation);
        }
    }

    public class GalleryPageTransformer implements ViewPager.PageTransformer
    {
        private static final float MAX_ROTATION = 20.0f;
        private static final float MIN_SCALE = 0.75f;
        private static final float MAX_TRANSLATE = 20.0f;

        @Override
        public void transformPage(View page, float position)
        {
            if (position < -1)
            {
                page.setTranslationX(MAX_TRANSLATE);
                page.setScaleX(MIN_SCALE);
                page.setScaleY(MIN_SCALE);
                page.setRotationY(-MAX_ROTATION);
            } else if (position <= 0)
            {
                page.setTranslationX(-MAX_TRANSLATE * position);
                float scale = MIN_SCALE + (1 - MIN_SCALE) * (1.0f + position);
                page.setScaleX(scale);
                page.setScaleY(scale);
                page.setRotationY(MAX_ROTATION * position);
            } else if (position <= 1)
            {
                page.setTranslationX(-MAX_TRANSLATE * position);
                float scale = MIN_SCALE + (1 - MIN_SCALE) * (1.0f - position);
                page.setScaleX(scale);
                page.setScaleY(scale);
                page.setRotationY(MAX_ROTATION * position);
            } else
            {
                page.setTranslationX(-MAX_TRANSLATE);
                page.setScaleX(MIN_SCALE);
                page.setScaleY(MIN_SCALE);
                page.setRotationY(MAX_ROTATION);
            }
        }
    }
}

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

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/types_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:dividerHeight="5dp" />

</LinearLayout>

activity_login.xml
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:stretchColumns="1" >
<!--    TableRow是没办法调节高度的,但是可以通过margin调节两个tablerow之间的间距以达到调节高度的作用-->
    <TableRow>

        <TextView
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:text="&#60;"
            android:textSize="20sp" />

        <TextView
            android:id="@+id/welcome"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="50dp"
            android:text="欢迎来到卷王の世界"
            android:textColor="@color/blue0"
            android:textSize="30sp" />

    </TableRow>

    <TableRow android:layout_marginTop="40dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/account"
            android:textSize="15sp"
            android:textColor="@color/black"
            android:layout_marginLeft="20dp" />

        <EditText
            android:id="@+id/account"
            android:layout_height="wrap_content"
            android:hint="输入你的账号"
            android:layout_marginLeft="10dp" />

    </TableRow>

    <TableRow>
        <TextView
            android:textSize="15sp"
            android:textColor="@color/black"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/password"
            android:layout_marginLeft="20dp"/>

        <EditText
            android:id="@+id/password"
            android:layout_height="wrap_content"
            android:inputType="textPassword"
            android:hint="输入你的密码"
            android:layout_marginLeft="10dp"/>

    </TableRow>

    <TableRow>
        <Button
            android:id="@+id/login"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_span="2"
            android:background="@color/gray0"
            android:layout_marginLeft="10dp"
            android:layout_margin="20dp"
            android:text="登录"   />
    </TableRow>

    <TableRow>
        <TextView
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:text="注册账号   |   忘记密码"
            android:layout_gravity="center"
            android:layout_span="2" />
    </TableRow>
    <TableRow
        android:gravity="center"
        android:layout_marginTop="60dp">
        <LinearLayout
            android:orientation="horizontal"
            android:layout_span="2"
            android:gravity="center">
            <ImageButton
                android:layout_marginRight="20dp"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:scaleType="centerInside"
                android:src="@drawable/qqq" />
            <ImageButton
                android:layout_marginRight="20dp"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:scaleType="centerInside"
                android:src="@drawable/wechat" />
            <ImageButton
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:scaleType="centerInside"
                android:src="@drawable/sms" />
        </LinearLayout>

    </TableRow>

</TableLayout>
activity_test_list_view.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"
    >
    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </ListView>
</LinearLayout>
activity_viewpager.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    tools:context=".ViewPagerActivity" >

    <androidx.viewpager.widget.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <androidx.viewpager.widget.PagerTitleStrip
            android:id="@+id/pager_title"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_gravity="top"
            android:background="@android:color/white"
            android:textColor="@color/black"
            android:textSize="18sp">

        </androidx.viewpager.widget.PagerTitleStrip>

    </androidx.viewpager.widget.ViewPager>

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

    <ImageView
        android:id="@+id/exam_type_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/exam_type_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textSize="24sp"
        android:layout_marginLeft="20dip" />

</LinearLayout>
quiz_pager1.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:background="#ffffff"
    android:orientation="vertical"
    android:layout_gravity="center">
    <RadioGroup
        android:id="@+id/group"
        android:layout_marginTop="50dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="30dp">
        <TextView
            android:id="@+id/quiz_view_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/question1"
            android:textSize="18sp"
            android:layout_marginBottom="30dp"/>
        <RadioButton
            android:id="@+id/A"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/option"/>
        <RadioButton
            android:id="@+id/B"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/option"/>
        <RadioButton
            android:id="@+id/C"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/option"/>
        <RadioButton
            android:id="@+id/D"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/option"/>
    </RadioGroup>


</LinearLayout>
quiz_pager2.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:background="#ffffff"
    android:orientation="vertical"
    android:layout_gravity="center">
    <RadioGroup
        android:id="@+id/group"
        android:layout_marginTop="50dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="30dp">
        <TextView
            android:id="@+id/quiz_view_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/question2"
            android:textSize="18sp"
            android:layout_marginBottom="30dp"/>
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="True"/>
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="False"/>
    </RadioGroup>


</LinearLayout>
quiz_pager3.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:background="#ffffff"
    android:orientation="vertical"
    android:layout_gravity="center"
    android:layout_margin="30dp">

    <TextView
        android:id="@+id/quiz_view_1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/question3"
        android:textSize="18sp"
        android:layout_marginTop="30dp"
        android:layout_marginBottom="20dp"
        android:layout_marginStart="30dp"/>

    <CheckBox
        android:id="@+id/option1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"/>
    <CheckBox
        android:id="@+id/option2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"/>
    <CheckBox
        android:id="@+id/option3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"/>
    <CheckBox
        android:id="@+id/option4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"/>
    <Button
        android:id="@+id/submit"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="30dp"
        android:layout_width="170dp"
        android:layout_height="50dp"
        android:text="提交答案"/>
    <TextView
        android:id="@+id/ans"
        android:layout_margin="30dp"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:textSize="18sp"
        android:text=""/>

</LinearLayout>
quiz_pager4.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:background="#ffffff"
    android:orientation="vertical"
    android:layout_gravity="center"
    android:layout_margin="30dp">

    <TextView
        android:text="@string/question4"
        android:id="@+id/quiz_view_1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15sp"
        android:layout_marginBottom="20dp"
        android:layout_marginStart="30dp"/>

    <EditText
        android:id="@+id/ans1"
        android:layout_marginStart="30dp"
        android:layout_width="200dp"
        android:layout_height="50dp"
        android:hint="@string/input"
        android:maxLines="10"/>

    <EditText
        android:id="@+id/ans2"
        android:layout_marginStart="30dp"
        android:layout_width="200dp"
        android:layout_height="50dp"
        android:hint="@string/input"
        android:maxLines="10"/>

    <EditText
        android:id="@+id/ans3"
        android:layout_marginStart="30dp"
        android:layout_width="200dp"
        android:layout_height="50dp"
        android:hint="@string/input"
        android:maxLines="10"/>
    <Button
        android:id="@+id/submit"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="30dp"
        android:layout_width="170dp"
        android:layout_height="50dp"
        android:text="@string/submit"/>

    <TextView
        android:id="@+id/ans"
        android:layout_margin="30dp"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:textSize="18sp"
        android:text=""/>

</LinearLayout>
quiz_pager5.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:background="#ffffff"
    android:orientation="vertical"
    android:layout_gravity="center"
    android:layout_margin="30dp">

    <TextView
        android:id="@+id/quiz_view_1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/question5"
        android:textSize="18sp"
        android:layout_marginBottom="20dp"
        android:layout_marginTop="50dp"
        android:layout_marginStart="30dp"/>

    <EditText
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:hint="@string/input"
        android:maxLines="10"/>
    <Button
        android:id="@+id/submit"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="50dp"
        android:layout_width="170dp"
        android:layout_height="50dp"
        android:text="@string/submit"/>

    <TextView
        android:id="@+id/ans"
        android:layout_margin="30dp"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:textSize="18sp"
        android:text=""/>
</LinearLayout>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值