Info

ÎlHÎifiÎS^JWftM^dï^jI» U\\-ÎAïmm//. & JEMRadioGroupActivity, tkflfcttMMif-JI]»/j;-RJadioGroupâlft, fî^tfêA - K Jt onCrcate Kffi^:

protected void onCreate(Bundle savedlnstanceState) { super.onCreate(savedlnstanceState) ; setContentView (R. layout.. radio group) ; setTitle("RadioGroupActivity");

mRadioGroup - (RadicGroup) findViewByld(R.id.menu); Button clearButton = (Button) findViewByld(R.id.clear); clearButton.setOnClickLisrener(this);

radiogroup.xml I:, ^inttN] setTitlc fêA Title ^"RadioGroupActivity", ^ig^RadioGroup^^fllfêÎIÎ^Î^o ftjfcfcifiλ«Aft. XiffifWfi 11 K0T7F:

<?xml version-"1.0" encoding="utf-8"?>

<LinearLayout xralns:Android="http://schémas.Android.com/apk/res/Android" Android: layout, width-" f i 1J pa rent " Android:layout height="fill parent" Androi d:orientâtion="vertical"> <RadioGroup

Android:layout wxdth="fill parent" Android: layout, height -"wrap content " Android : or ien ta ti.on=" vertical" Android:checkëdButton="3 I id/lunch" Android:id "@+id/menu"> <RadioButton

Android:text="breakfast" Android:id-♦id/break fast" />

<RadioButt.on

Android : text. = " lunch" Android :id="@ id/lunch" /> <RadioButton

Android:text-"dinner" Android: id="@+ id/dinner" /> <RadioButton

Android:text="all" Android :id="@ + id/ail" /> </Rad i oGroup> <Button

Android:layout width="wrap_content" Android:layout height="wrap_content" Android: text -

Android : id-"(? +id/clear" /> </LinearLayout>

ÎëWr t'ï'-jitHKRadioGroup). ÎÇ+iï^T 4 #>h"|ii]ÎK]#î£ft ai < Radio >, VJ.& ft F ® ii t- m It ( clear ) ft ft fll . fl % ft

RadioGroupActivity - KfB*. iffl?_L8 Rad1oriro,jp „

7.3.7 Tfe5iJ3ft ( Spinner ) ^ffl^fiffl

«»^Miiiffl. mmmrm'tm. main.xmi itM'» -^mu ft'M^Pi^J.&'t SpinncrActivity if| * Button iKMWi&l

<Button Android:id="@+id/spinner button"

Android:layout width="wrap content" Android:layout_height "wrap_content" Android:text="Spinner" />

\immft:

fcX id X) 44spinner button" Mttfll. JtflEJ®#l!5JKfi6fiK«, Jf'-iB/feJCE^A'T-

% 44 Spinner "o

private Button .OnClickListener spinner but: ton_iistener = new Button.OnClickListener() { public void onClick(View v) ( Intent intent new Intent();

intent.setClass(Mai nActivity.this, SpinnerActi vity.class);

startActivity(intent); }

h iWWft:

''JWffiiSSM^^JifftlW«, In*)} SpinncrActivity, SpinnerActivity

Spinner mftMff'lflio ftfi'M SpinncrActivity lA't Activity, onCreate fj public void onCreate(Bundle savedlnstanceState) f super.onCreate(savedlnstanceState) ; setTitle("SpinnerActivity") ;

setContentView(R.layout.spinner); »

setTitle A 44SpinnerActivity )m spinner.xml itffiti A ft .

^*1»faK-Xi/S(W«S®iCitspinner.xnil, Text View #1 Spinner 81 ft-.

<TextView

Android:layout_width="fi1l_parent" Android: layout_height - "wrap_content." Android:text "Spinner 1" />

<Spi nner Android:id="@+id/spinner_l"

Android:layout_width="fill parent" Android:layout height="wrap contenL" Android: drawSelect:.orOnTop=" false"

&'M&K Zftl\r>iI X r ^ Text View *flfl ill Spinner fitfiVh AndroidManifest.xml 't'iSiWittl KfW:

<activity Android:name-"SpinnerActivity"x/acti vity>

SfflSl&M Spinner fäiWi id spinner 1. jÈMAfà&X JÙ& ( LinearLayout ) A" ÏJ fi JSJÈÎ =

Aft! 7-19 l-.BjWfi-iii, ftiB kLi»..W^7 -t KiiUHt. fHJi it'mmmnikm. K mi M M im % -mm,

% Spinner

SpinnerActh/ity

SpinnerActh/ity

7-19 Spinner private static final String!] mCountries = "Ukraine", "Belarus", "USA" };

I "China" , "Russia", "Germany",

^^{Jt r/LtW^^M^WPia», $hift onCrcatc Jjik'I1 WJfl find and modify_view()*-

2RA3SIB. find and modify view()ftjfWillT0MS:

private void find_and_modify view() { spinner c (Spinner) findViewByld(R.id.spinner 1)? allcountries = new ArrayList<String> () ; for (int i = 0; i < mCountries.length; i++) \ allcountries.add(mCountries[i]); )

aspnCountries = new ArrayAdapter<String>(this, Android.R.layout.simple spinneritem, allcountries); aspnCountries

. set DropDownViewResource (Android. R. layout .simple spinner_dropdown_i.tem) ;

spinner_c-. set Adapter (aspnCountries) ;

hi£{ M mCountries ftJBKtt £J Spinner

(2) ft XML iff^SiSXtffic

1$ ( tm»mt'41 Spinner rtSfttffiii'h iinfWtf. XML Stftt'SifeSiiX»«. ^TiMj&^ffift, ft spinner.xml

Kft^flSSsiin-^ Spinner iflfr. K0pj5:

<TextView

Android:layout width-"fillparent" Android:layout height="wrap_content" Android:text="Spinner 2 From arrays xml file" />

<Spinner Android:id="@+id/spinner_2"

Android:layout_width="fi11 parent" An d rai d:1a you t_he i gh t = "w ra p cont en t" Android:drawSelectorOnTop- "faise"

re

'FW

0 0

Post a comment