安卓开发实验报告.docx

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

安卓开发实验报告.docx

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

安卓开发实验报告.docx

安卓开发实验报告

安卓开发实验报告

一、页面跳转

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

 

一、页面跳转

功能:

通过点击button实现2个activity之间的跳转。

1.设置监听器监听点击button

2.使用intent传输数据

完整代码

classUI_TestextendsActivity{

@Override

protectedvoidonCreate(BundlesavedInstanceState){

(savedInstanceState);

setContentView

Buttonbt=(Button)findViewById(newOnClickListener());

}

classOnClickListenerimplements{

publicvoidonClick(Viewv){

EditTextname=(EditText)findViewByIdEditTextpassword=(EditText)findViewById

Bundledata=newBundle();

("name",().toString());

("password",().toString());

Intentintent=newIntent,;

(data);

startActivity(intent);

}

}

classUI_ResultextendsActivity{

@Override

protectedvoidonCreate(BundlesavedInstanceState){

(savedInstanceState);

setContentView

TextViewname=(TextView)findViewByIdTextViewpassword=(TextView)findViewById

Intentintent=getIntent();

Bundleresult=();

("您的用户名为:

"+("name"));

("您的密码为:

"+("password"));

}

}

version=""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"

/>

version=""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.

publicclassMainActivityextendsActivity{

privatePackageManagermPackageManager;

privateGridViewmAppGrid;

privateListmAppList;

privateDrawablemColorDrawable;

privateGridViewAdaptermAdapter=null;

privatestaticintmAppState=0;

privatestaticfinalintAPP_DELFINISHED=0x1;

publicMainActivity(){

etDefaultDisplay();

intwidthPIX=();

finalfloatscale=getResources().getDisplayMetrics().density;

nCol=(int)(widthPIX/scale/80);

returnnCol;

}

/*privateclassPicOnTouchListenerimplementsOnTouchListener{

@Override

publicbooleanonTouch(Viewv,MotionEventevent){

if(mAppState==1){

resetAllAppIcon();

}

returntrue;

}

}*/

}

2.GridViewAdapter

publicclassGridViewAdapterextendsBaseAdapter{

ListmAppList=null;

PackageManagermPackageManager=null;

ViewmView=null;

ContextmContext=null;

publicGridViewAdapter(Listlist,Contextcontext,PackageManagermanager){

mAppList=list;

mContext=context;

mPackageManager=manager;

}

@Override

publicintgetCount(){

return();

}

@Override

publicObjectgetItem(intposition){

return(position);

}

@Override

publiclonggetItemId(intposition){

returnposition;

}

@Override

publicViewgetView(intposition,ViewconvertView,ViewGroupparent){

ImageViewi;

TextViewt;

if(convertView==null){

convertView=(mContext).inflatenull);

}

i=(ImageView)t=(TextView)PackageInfoinfo=(position);

returnconvertView;

}

publicvoidsetData(Listlist){

mAppList=list;

}

}

3.

android=""

android:

layout_width="match_parent"

android:

layout_height="match_parent"

android:

layout_marginTop="20dip"

android:

layout_marginBottom="20dip"

android:

layout_marginLeft="10dip"

android:

layout_marginRight="10dip"

android:

orientation="vertical">

android:

id="@+id/app_list_grid"

android:

layout_width="match_parent"

android:

layout_height="match_parent"

android:

verticalSpacing="0dip"

android:

horizontalSpacing="0dip"

android:

numColumns="5">

4.

android=""

android:

layout_width="wrap_content"

android:

layout_height="wrap_content">

android:

id="@+id/icon_framelayout"

android:

layout_centerInParent="true"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content">

android:

id="@+id/view_app_info"

android:

layout_width="fill_parent"

android:

layout_height="fill_parent"

android:

orientation="vertical"

android:

layout_marginTop="5dip"

android:

layout_marginBottom="5dip"

android:

layout_marginLeft="5dip"

android:

layout_marginRight="5dip"

android:

visibility="visible">

android:

id="@+id/img_appicon"

android:

layout_width="@android:

dimen/app_icon_size"

android:

layout_height="@android:

dimen/app_icon_size"

android:

contentDescription="@null"

android:

layout_gravity="center_horizontal"

android:

src="@drawable/ic_launcher"/>

android:

id="@+id/txt_appname"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

textSize="12sp"

android:

maxLines="2"

android:

layout_gravity="center_horizontal"

/>

android:

id="@+id/view_delete"

android:

layout_width="fill_parent"

android:

layout_height="fill_parent"

android:

visibility="invisible">

android:

id="@+id/cross_icon"

android:

layout_width="24dp"

android:

layout_height="24dp"

android:

layout_alignParentRight="true"

android:

layout_alignParentTop="true"

android:

padding="0dp"

android:

src="@drawable/ic_delete"/>

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

当前位置:首页 > 表格模板 > 调查报告

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

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