2024年4月1日发(作者:)

用纯代码实现RadioGroup,并且实现滚动条

import ty;

import ;

import Params;

import Layout;

import utton;

import roup;

import View;

import ew;

public class QuestionActivity extends Activity {

private TextView mTextView1, mTextView2, mTextView3,mTextView4;

private RadioGroup mRadioGroup1,mRadioGroup2,mRadioGroup3;

private RadioButton

mRadio1,mRadio2,mRadio3,mRadio4,mRadio5,mRadio6,mRadio7,mRadio8,mRadio9;

private ScrollView mScrollView;

Params mRadioParams;

Params mLineparams;

public void onCreate(Bundle savedInstanceState)

{

te(savedInstanceState);

final int sWrapContent = _CONTENT;

final int sFileParent = _PARENT;

mScrollView = new ScrollView(this);

outParams(new LayoutParams(sFileParent,

sWrapContent));

LinearLayout sLinerLayout = new LinearLayout(this);

//sLinerLayout.

kgroundResource();

outParams(new

LayoutParams(sFileParent,sFileParent));

entation(AL);

mLineparams = new Params(sWrapContent,sWrapContent);

w(sLinerLayout);

mTextView1 = new TextView(this);

t("请问你是");

w(mTextView1,mLineparams);

mRadioGroup1 = new RadioGroup(this);

entation(AL);

// mParams = new Params(137,216);

mLineparams = new Params(sWrapContent,sWrapContent);

w(mRadioGroup1,mLineparams);

mRadio1 = new RadioButton(this);

t("帅哥");

(1001);

mRadioParams = new Params(sWrapContent,sWrapContent);

w(mRadio1, mRadioParams);

mRadio2 = new RadioButton(this);

t("美女");

(1002);

mRadioParams = new Params(sWrapContent,sWrapContent);

w(mRadio2, mRadioParams);

mTextView2 = new TextView(this);

t("2010南非世界杯季军是");

w(mTextView2,mLineparams);

mRadioGroup2 = new RadioGroup(this);

entation(AL);

// mParams = new Params(137,216);

mLineparams = new Params(sWrapContent,sWrapContent);

w(mRadioGroup2,mLineparams);

mRadio3 = new RadioButton(this);

t("西班牙");

(1003);

mRadioParams = new Params(sWrapContent,sWrapContent);

w(mRadio3, mRadioParams);

mRadio4 = new RadioButton(this);

t("荷兰");

(1004);

mRadioParams = new Params(sWrapContent,sWrapContent);

w(mRadio4, mRadioParams);

mRadio5 = new RadioButton(this);

t("德国");

(1005);

mRadioParams = new Params(sWrapContent,sWrapContent);

w(mRadio5, mRadioParams);

mTextView3 = new TextView(this);

t("2010亚运会在哪个城市举行: ");

w(mTextView3,mLineparams);

mRadioGroup3 = new RadioGroup(this);

entation(AL);

// mParams = new Params(137,216);

mLineparams = new Params(sWrapContent,sWrapContent);

w(mRadioGroup3,mLineparams);

mRadio6 = new RadioButton(this);

t("北京");

(1006);

mRadioParams = new Params(sWrapContent,sWrapContent);

w(mRadio6, mRadioParams);

mRadio7 = new RadioButton(this);

t("上海");

(1007);

mRadioParams = new Params(sWrapContent,sWrapContent);

w(mRadio7, mRadioParams);

mRadio8 = new RadioButton(this);

t("广州");

(1008);

mRadioParams = new Params(sWrapContent,sWrapContent);

w(mRadio8, mRadioParams);

mRadio9 = new RadioButton(this);

t("深圳");

(1009);

mRadioParams = new Params(sWrapContent,sWrapContent);

w(mRadio9, mRadioParams);

mTextView4 = new TextView(this);

t("答案: ");

w(mTextView4,mLineparams);

setContentView(mScrollView);

heckedChangeListener(mChangeRadio);

heckedChangeListener(mChangeRadio);

heckedChangeListener(mChangeRadio);

}

private kedChangeListener mChangeRadio = new

kedChangeListener()

{

public void onCheckedChanged(RadioGroup group, int checkedId)

{

// TODO Auto-generated method stub

if(checkedId==())

{

/*把mRadio1的内容传到mTextView1*/

t(t());

}

else if(checkedId==())

{

/*把mRadio2的内容传到mTextView1*/

t(t());

}

else if(checkedId==())

{

/*把mRadio3的内容传到mTextView2*/

t(t());

}

else if(checkedId==())

{

/*把mRadio4的内容传到mTextView2*/

t(t());

}

else if(checkedId==())

{

/*把mRadio5的内容传到mTextView2*/

t(t());

}

else if(checkedId==())

{

/*把mRadio2的内容传到mTextView4*/

t("答案: " + t());

}

else if(checkedId==())

{

/*把mRadio7的内容传到mTextView4*/

t("答案: " + t());

}

else if(checkedId==())

{

/*把mRadio8的内容传到mTextView4*/

t("答案: " + t());

}

else if(checkedId==())

{

/*把mRadio9的内容传到mTextView4*/

t("答案: " + t());

}

}

};

}