安卓开发实验报告.docx
- 文档编号:236855
- 上传时间:2022-10-07
- 格式:DOCX
- 页数:13
- 大小:177.70KB
安卓开发实验报告.docx
《安卓开发实验报告.docx》由会员分享,可在线阅读,更多相关《安卓开发实验报告.docx(13页珍藏版)》请在冰豆网上搜索。
安卓开发实验报告
目录
一、页面跳转
二、长按图标抖动以及显示删除
一、页面跳转
功能:
通过点击button实现2个activity之间的跳转。
1.设置监听器监听点击button
2.使用intent传输数据
完整代码
1.ui_test.java
publicclassUI_TestextendsActivity{
@Override
protectedvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.incident_activity_1);
Buttonbt=(Button)findViewById(R.id.login);
bt.setOnClickListener(newOnClickListener());
}
classOnClickListenerimplementsView.OnClickListener{
publicvoidonClick(Viewv){
EditTextname=(EditText)findViewById(R.id.name);
EditTextpassword=(EditText)findViewById(R.id.password);
Bundledata=newBundle();
data.putString("name",name.getText().toString());
data.putString("password",password.getText().toString());
Intentintent=newIntent(UI_Test.this,UI_Result.class);
intent.putExtras(data);
startActivity(intent);
}
}
2.ui_result.java
publicclassUI_ResultextendsActivity{
@Override
protectedvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.incident_activity_2);
TextViewname=(TextView)findViewById(R.id.nameShow);
TextViewpassword=(TextView)findViewById(R.id.passwordShow);
Intentintent=getIntent();
Bundleresult=intent.getExtras();
name.setText("您的用户名为:
"+result.getString("name"));
password.setText("您的密码为:
"+result.getString("password"));
}
}
3.activity_1.xml
xmlversion="1.0"encoding="utf-8"?
>
android=" android: layout_width="fill_parent" android: layout_height="fill_parent" > android: layout_width="fill_parent" android: layout_height="wrap_content" android: text="请输入您的信息" android: textSize="20sp" /> android: id="@+id/tableRow1" android: layout_width="fill_parent" android: layout_height="wrap_content" > android: layout_width="fill_parent" android: layout_height="wrap_content" android: text="用户名" android: textSize="16sp" /> android: id="@+id/name" android: layout_width="fill_parent" android: layout_height="wrap_content" android: hint="请填写登录用户名" android: selectAllOnFocus="true"> android: id="@+id/tableRow2" android: layout_width="fill_parent" android: layout_height="wrap_content" > android: layout_width="fill_parent" android: layout_height="wrap_content" android: text="请输入密码" android: textSize="16sp" /> android: id="@+id/password" android: layout_width="fill_parent" android: layout_height="wrap_content" android: password="true" android: selectAllOnFocus="true"> android: id="@+id/tableRow3" android: layout_width="fill_parent" android: layout_height="wrap_content" > 4.activity_2.xml xmlversion="1.0"encoding="utf-8"? > android=" android: layout_width="match_parent" android: layout_height="match_parent" android: orientation="vertical"> android: id="@+id/nameShow" android: layout_width="fill_parent" android: layout_height="wrap_content" android: textSize="18sp" /> android: id="@+id/passwordShow" android: layout_width="fill_parent" android: layout_height="wrap_content" android: textSize="18sp" /> 二、长按图标抖动以及显示删除 功能: 将app列举在界面上,并且长按图标使图标进行抖动以及显示删除图标。 1.初始化一个gridview的适配器 2.通过不停转动图标实现图标的抖动以及添加删除图标 3.添加监听器实现长按图标使图标抖动及显示删除 完整代码 1.main_activity.java publicclassMainActivityextendsActivity{ privatePackageManagermPackageManager; privateGridViewmAppGrid; privateList privateDrawablemColorDrawable; privateGridViewAdaptermAdapter=null; privatestaticintmAppState=0; privatestaticfinalintAPP_DELFINISHED=0x1; publicMainActivity(){ //TODOAuto-generatedconstructor
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 开发 实验 报告