作者 zhangtao

答题页面重写

package com.hh.xuetubao.activity.pratice;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
import com.hh.xuetubao.adapter.ListAnswerAdapter;
import com.hh.xuetubao.bean.AnswerBean;
import com.hh.xuetubao.model.ExerciseModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 随机练习页面
*/
public class a extends BaseMvpActivity<CommonPresenter, ExerciseModel> implements ICommonView, View.OnClickListener {
@BindView(R.id.list_answer)
ListView listAnswer;
@BindView(R.id.tv_radio)
TextView tvRadio;
@BindView(R.id.tv_max)
TextView tvMax;
@BindView(R.id.tv_current)
TextView tvCurrent;
@BindView(R.id.tv_title)
TextView tvTitle;
@BindView(R.id.tv_topic)
TextView tvTopic;
@BindView(R.id.rl_last)
RelativeLayout rlLast;
@BindView(R.id.rl_next)
RelativeLayout rlNext;
@BindView(R.id.index)
TextView index;
@BindView(R.id.all)
TextView all;
@BindView(R.id.tv_right_num)
TextView tvRightNum;
@BindView(R.id.tv_wrong_num)
TextView tvWrongNum;
@BindView(R.id.lin_tab)
LinearLayout linTab;
@BindView(R.id.rl_card)
RelativeLayout rlCard;
@BindView(R.id.right_select)
TextView rightSelect;
@BindView(R.id.right_answer)
TextView rightAnswerText;
@BindView(R.id.rl_answer)
RelativeLayout rlAnswer;
@BindView(R.id.commit)
LinearLayout commit;
@BindView(R.id.tv2)
TextView tv2;
@BindView(R.id.tv_show_card)
TextView tvShowCard;
private String catalogOid;
private String accountOid;
private int listIndex = 0; //数据下标
private String type;//题目类型
private List<AnswerBean.QuestionLstBean> questionLst = new ArrayList<>();//创建集合存储这一套题
private ListAnswerAdapter optionsAdapter;
@Override
public void initView() {
accountOid = SharedPrefrenceUtils.getString(this, "AccountOid");
catalogOid = getIntent().getStringExtra("catalogOid");
rlLast.setOnClickListener(this);
rlNext.setOnClickListener(this);
linTab.setOnClickListener(this);
rlCard.setOnClickListener(this);
commit.setOnClickListener(this);
tvShowCard.setOnClickListener(this);
listAnswer.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
});
}
@Override
public int initLayout() {
return R.layout.activity_answer_sheet;
}
@Override
public void initData() {
mPresenter.getPresenter(8, 1, catalogOid, String.valueOf(10), accountOid);
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public ExerciseModel getModel() {
return new ExerciseModel();
}
@Override
public void getData(Object o, int api, int intent) {
if (api == 8 && intent == 1) {
AnswerBean bean = (AnswerBean) o;
List<AnswerBean.QuestionLstBean> questionLstBeans = bean.getQuestionLst();
questionLst.addAll(questionLstBeans);
tvMax.setText(String.valueOf(questionLst.size()));
all.setText(String.valueOf(questionLst.size()));
tvTopic.setText(questionLstBeans.get(listIndex).getQuestionTitle());
tvCurrent.setText(String.valueOf(listIndex + 1));
type = questionLstBeans.get(listIndex).getQuestionTypeName();
tvRadio.setText(type);
optionsAdapter = new ListAnswerAdapter(questionLst.get(listIndex).getOptionsLst(), this);
listAnswer.setAdapter(optionsAdapter);
}
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.rl_last:
break;
case R.id.rl_next:
break;
case R.id.lin_tab:
this.finish();
break;
case R.id.rl_card:
break;
case R.id.tv_look:
break;
case R.id.commit:
break;
case R.id.tv_show_card:
break;
}
}
}
... ...