Cxl

V CnwM Activity iiSjSiSr ~ SM fmi* "S

tlDllh C KKll

main.xml, I'.iSSt

Button««liaEfE^imt^ttiftfttt-'Sfwac. JI- -mm K^M mnift, wan. IHP

■teamis*. ■gmidtt* a^^Fiwi^ffl i-jr» -i-sm srr&ftjnHtt

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

<L i near Layout xmlns : Android="h ttp: //schemas . Android. com/apk/ res/Andro.i d" Android:orientation="vertical" Android:layout width "fill parent" Android:1ayout height "fill pa rent">

Android:layout_width="wrap_content" Android:layout_height="wrap content" Android: text="ie*J§k button" />

IJ&fTOi^, -t Android:id %} button tf-}&m, (layout width)

111^/3: (layoutheight) (wrap_content), ft-ft^SM^fiW:5?^ "M button",

private void find and modify button() {

Button button (Button) findViewByld(R.id.button);

button.setOnClickListener(button listener); }

Button, mfeim setOnClick n/ifiS>J button listener, button listener, Kfttfjjffl "F/TpF:

private Button.OnClickListener button listener = new Button.OnClickListener() | public void onCiick(View v) (

setTitleC'BxQfe, button ;

lilKffiffiifJ setTitle ttftSttCft button Mti 7

Twt mmmmf?. fcfW*H7-u j^m^ffl T«mm\l, miI-^^ioUS»/ftu^iKi"/fi^yy^, fm, ihJtfTJF Activity iiUfc-filHift, WWHiiJtt'filWJftiriiiinitt».

TextView W^lflfo ill 7.3.2'M? -ff-. main.xml ilt^ftl"Button -JttftR

It id ^J text view button, ^flt^Wiin h'#T>J<:

<But ton Android : id- "3 +• id/text_view_button"

Android:layout_width="wrap content" Android:laybut_height="wrap_content" Android:text«"TextView" />

id %) "text_view button" fftgcfll, iC'7 'M "TextView"«,

MainActivity 11' m Ml M & ^ ft ftl tfj tfi., | fl ■: (fj lift r il Infl Ky, ^

fJ'JT* TextView MM/tfftlfif. iWftA find and modify button ^S^iS/JP^lft text view button iftiW. HWtoi Fffric:

I Button text view button = (Button) findViewByld(R.id.text view button); text view button.setOnClickListener(text view button_listener);

fllliuiiil^to, view button listener, ^ti'JWrtfJ K

(iii. «'iMWin Ks private Button .OnClickL,stener text view button listener = new Button .OnClick Listener () {

public void onClick(View v) { Intent intent new Intent ();

intent. setClass (MainAct ivi ty. this, TextActivit-y.class); startActivity(intent); I

M.ir.flBiftiWuTKJUitfJt ft*fcfi'Jtt -^Intent, «uswrajs setciass #

&&& iCrix«-BfeH-l^J Activity, TextActivity, M/fi i^HJ startActivity fi JPS t Vf liii.

jjl^s. ^ HU Mtt&tt&frJSI ^ TextActivity, jfY+Jt ^ TextView G'J*£ Activity wy/feiulflfri-fip-. iAK^f^J TextActivity, «Jg»««»- K& onCreate ikiC*»&il]

public void onCreate(Bundle savedlnstanceState) ( public void onCreate(Bundle savedlnstanceState) ( super.onCreate(savedlnstanceState); setTit1e("ViewTextActivity") ; setContentView(R.layout.text) ; )

AM^WwrW^Ui, ft*]*»* TextActivity text.xml I ., Jt Title

"TextActivity", ^ ft text.xml -^TextView, ^SM^Bill TffW:

<?xml version=" 1. 01' encoding="utf-8"?>

<LinearLayout xmlns:Android="http://schemas.Android.com/apk/res/Android" Android:orientation8*"vertical" Android: layout width="f ill_parent"

Android:layout height="fili_parent"

CTextView

Android: id="@+id/text_view" Android:layout_width="fill_parentM Android:layout height="wrap_content" Android:textSize=w16sp" Android:textColor""#ffffff" Android:padding="1Odip" Android:background="ttccOOOO"

Android: text="i£Mjt TextView, ."

</LinearLayouL>

H fWlfif:

hffittW+BSill7—^ TextView fflfHti. Android.id iJLttitttfH

ttfeiU. Android-.textSize Android:padding

Android:background android:textColor JU^&Jg^ttfftlfBCi, Androiditext S&jtfi frft-JOfflMW, afi^iififjjtS^c^E^H^Hi I8dip, ttffl 20sp M^'-iim & TextView. ffcniWi^ffi^iAflSg-M^jX^HM..". fr&ZlS, ZWffiStt WsJittW

i <1 . ^TextActivity >$UjU$iJ AndroidManifest.xml xttt. K^pi)pflj<application>«rt^i!(,:

<act i vit y Android: ndme= "ViewTextActivity"x/activity>

AkJgJsfT 'T&^lfcli. <£ "ViewText" «01, "J*gj^fji](illffl 7-12

TextView itij iK £ HfeMKffc, "I Android SDK

■Android

0 0

Post a comment