安卓开发实验报告.docx

上传人:b****1 文档编号:236855 上传时间:2022-10-07 格式:DOCX 页数:13 大小:177.70KB
下载 相关 举报
安卓开发实验报告.docx_第1页
第1页 / 共13页
安卓开发实验报告.docx_第2页
第2页 / 共13页
安卓开发实验报告.docx_第3页
第3页 / 共13页
安卓开发实验报告.docx_第4页
第4页 / 共13页
安卓开发实验报告.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

安卓开发实验报告.docx

《安卓开发实验报告.docx》由会员分享,可在线阅读,更多相关《安卓开发实验报告.docx(13页珍藏版)》请在冰豆网上搜索。

安卓开发实验报告.docx

安卓开发实验报告

目录

一、页面跳转

二、长按图标抖动以及显示删除

一、页面跳转

功能:

通过点击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"

>

android:

id="@+id/login"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

text="登录"

android:

textSize="16sp"

/>

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;

privateListmAppList;

privateDrawablemColorDrawable;

privateGridViewAdaptermAdapter=null;

privatestaticintmAppState=0;

privatestaticfinalintAPP_DELFINISHED=0x1;

publicMainActivity(){

//TODOAuto-generatedconstructor

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 自然科学 > 天文地理

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1