2023年Android实验报告.pdf





《2023年Android实验报告.pdf》由会员分享,可在线阅读,更多相关《2023年Android实验报告.pdf(12页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、创建一个名为“登录页面”的布局文献,该文献用于展示登录信息。程序界面如下图所示:p ack a g e co m.e x ample.mylayoutl;i mpo r t a n dro i d.a p p.Ac t ivi t y;impor t a n d ro i d.conten t.C o nte x t;1 mp o r t and r oid.c onten t.I ntent;im por t andro 1 d.co n t e nt.Shar e d P refere n ces;1 mport andro 1 d.o s.Bu n die;impo r t and r
2、oid.v ie w.Menu;1 mport andro i d.v ie w.V i e w;impo r t an d roi d.widg e t.E ditT e x t;im p o r t and r oid.w i dget.Toast;p ublic cla s s Ac t n v ity O le x te n d s A c t iv 1 t y。E d it T e xt n ame;。Ed i tTex t p a s s ;pro t e c te d void o nCreate(Bund 1 e sa vedlns ta n ceS t ate)。s u p
3、er.o n C r eate(s ave dl n stanc e St a te);3 Set C o ntentView(R.ayou t.mylin e);nam e 二(Edi t T e xt)fin d ViewByld(R.l d.edi t T ex t 1);b pass=(EditTe x t)findView Byld(R.id.ed itTe x t2);p ubl 1 c v oi d c 1 ic k(V i ew view)I nte n t i n te n t l=n ew In t ent(t his.MylayoutlMainAc t ivity.cla
4、ss);startActivity(i n t e n tl);pu b 1 ic vo i d c 1 ic k 1 (V ie w v i e w)Shared P refe fe n c e s sf1=getSharedPre f e r ences(acc o un t,C ontext.MODE_ PRIVATE);S t ring n am e 1=s fl.ge t S t r i n g(name ,);Str i n g pa s sl=s f l.getStrin g(pass,);3 S t rin g name2=n a me.g e t T ext().t oStr
5、i n g();S t ri n g pa s s2=p a ss.ge t T ex t().t oS t ring();。1 f(n a mel.e quals(n a me2)&p a s s i.eq uals(pa s s 2)Int e nt intent2=n e w Int e n t(t his,Tex t view 1 .c la ss);。i nte n t2.putEx t ra(n a me,n a mel);。inte n t 2.putE x t ra(pas s,pass 1 );。star t Ac t ivity(i ntent2);e lseStri ng
6、 c o=您的用户名或密码错误;6 Toa s t.makeText(t h is,co.t o S t ri n g(),10 00).show();private S haredPreferences g e t Share d P r eference()。return n u II;a 5554:AIDX3,M 2:19扁I ActivityOl OMD M M MD用户名密 码HMtfwai*KeyboardUM yvut ItvykMM to prov4 ta(MI登陆注册aa1创建一个名为“注册页面”的布局文献,该文献用于展示登录信息。程序界面如下图所示:pac k a g e
7、com.exam p 1 e.mylayou t 1;im p ort android,o s.Bu n die;impo r t android.app.Ac t i vity;i mport a ndro i d.c onte n t.I n t ent;impo r t android.content.Sha r e dPr e fe r e n ces;import a n droid,c ontent.S haredPreferences.Ed i tor;impo r t androi d.view.Menu;impo r t a nd r oid.v iew.View;1 m p
8、o r t a n d ro id.widget.CheckBo x;impo r t and r oid.widge t.Ed itT ex t;i mport a n d r oid.widg e t.R a d i oButt o n;i mpo r t a n d ro id .w id get.R a dioGr o u p;impor t a nd r oid.wid g et.S pi n ner;import a ndroid.widget.TextVi ew;p u b 1 ic class M y layoutlM a in Act 1 v i t y exte n d s
9、 Ac t i vi t yE d i t T ext uname;EditT ext upass;R a dioB u tton ra d iol;Radi o Button r a d i o2;Ra d ioGr o u p gr o up 1 ;S t rin g sex;String name;S t ring pass;Che c k Box b oxi;C heckBo x box2;C hec k Box box3;Ch e ckBox bo x 4;S tring strl;S t ring str2;String s tr3;S trin g s t r 4;Spin n
10、er s p;S tring sp 1 ;0 v e r r i d ee p r ote c t e d v o id o n C re ate(Bun d Ie sa v ed Instan c eS t ate)。super.o n Create(save d I n stan c eState);setC ontentV i ew(R.1 a y out.m y layoutl_main);gro u p 1=(RadioG r o up)findViewByld(R.i d.rad i oGroupl);。u nam e=(Ed 1 tText)f i n dV i e wBy I
11、d(R.i d.editTe x;3 u pass=(Edi t Te x t)findV i ewBy I d(R.id.editTex t 3);o boxl=(C hee kBox)find ViewByld(R .id.c h ec k B ox 1);。bo x 2=(Chec k Box)fi n d Vi e wByld(R.id.ch e ckBo x 2);b ox3=(Ch ec k Bo x)find View By ld(R.id.c heckBox3);box4=(CheckBox)findViewBy I d(R.id.checkBox4);。sp=(Spinne
12、r)fin d V ie w B y I d(R.id.spin n erl);。0ve r rid e。public b oole a n onC r eateOption s Me n u(M e nu menu)e /Inflate the men u;th is a d d s i t ems t o the ac t ion bar i f it is pres e n t.getM e nu I nfla t e r(),i nflat e(R.m e n u.mylayoutl_ ma i n,me n u);ret u rn t rue;pu b 1 i c void clic
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2023 Android 实验 报告

限制150内