Android intent and activity经典程序
#massage_box {
position: absolute;
left: expression((body.clientwidth-350)/ 2 );
top: expression((body.clientheight-200)/ 2 );
width: 350px;
height: 200px;
z-index: 2;
visibility: hidden
}
#mask {
position: absolute;
top: 0;
left: 0;
width: expression(body.scrollwidth);
height: expression(body.scrollheight);
background: #d3ddea;
filter: alpha(opacity =50);
z-index: 1;
visibility: hidden
}
Java代码
//数据写入intentintent openwelcomeactivityintent=new intent();bundle mybundelforname=new bundle();mybundelforname.putstring("key_name",inname.gettext().tostring());mybundelforname.putstring("key_age",inage.gettext().tostring());openwelcomeactivityintent.putextras(mybundelforname);openwelcomeactivityintent.setclass(androidbundel.this, welcome.class);startactivity(openwelcomeactivityintent);//从intent 中获取数据bundle mybundelforgetname=this.getintent().getextras();string name=mybundelforgetname.getstring("key_name");
Java代码
package zyf.android.study;import ……import android.content.intent;import android.net.uri;import android.view.view.onclicklistener;public class androidstudy_two extends activity {@overridepublic void oncreate(bundle savedinstancestate) {super.oncreate(savedinstancestate);setcontentview(r.layout.main);final edittext inname = (edittext) findviewbyid(r.id.name);final textview result = (textview) findviewbyid(r.id.result);button button_start_browser = (button) findviewbyid(r.id.submit_tonet);button button_login=(button) findviewbyid(r.id.show_login);button button_showloginname=(button)findviewbyid(r.id.submit_toshowloingname);button_start_browser.setonclicklistener(new onclicklistener(){@overridepublic void onclick(view v) {uri myuri = uri.parse("http://www.flashwing.net");intent openbrowserintent = new intent(intent.action_view,myuri);startactivity(openbrowserintent);}});button_login.setonclicklistener(new onclicklistener(){@overridepublic void onclick(view v) {intent openwelcomeactivityintent=new intent();openwelcomeactivityintent.setclass(androidstudy_two.this,welcome.class);startactivity(openwelcomeactivityintent);}});button_showloginname.setonclicklistener(new onclicklistener(){@overridepublic void onclick(view v) {result.settext(inname.gettext()+"欢迎您进入");}});}}
相关新闻>>
- 发表评论
-
- 最新评论 更多>>