位置: 编程技术 - 正文
推荐整理分享android各种控件的事件监听及举例(andriod 控件),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:安卓app控件,android常用控件大全,安卓控件属性有哪些,andriod 控件,android常用控件大全,android控件大全及用法,android界面控件,android常用控件大全,内容如对您有帮助,希望把文章链接给更多的朋友!
原帖地址: version="1.0" encoding="utf-8"?><menu xmlns:android=" <item android:id="@id/apple" android:title="苹果" /> <item android:id="@id/banana" android:title="香蕉" /> <item android:id="@id/exit" android:title="退出" /></menu>第六个例子:对话框的事件处理package org.hualang.dialog;import android.app.Activity;import android.app.AlertDialog;import android.app.Dialog;import android.app.ProgressDialog;import android.content.DialogInterface;import android.content.DialogInterface.OnClickListener;import android.os.Bundle;import android.view.LayoutInflater;import android.view.View;public class MainActivity extends Activity { /** Called when the activity is first created. */ ProgressDialog myDialog; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Dialog dialog = new AlertDialog.Builder(MainActivity.this) .setTitle("登录提示") .setMessage("这里需要登录") .setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub LayoutInflater factory = LayoutInflater.from(MainActivity.this); final View DialogView = factory.inflate(R.layout.dialog, null); AlertDialog dlg = new AlertDialog.Builder(MainActivity.this) .setTitle("登录框") .setView(DialogView) .setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { // TODO Auto-generated method stub myDialog = ProgressDialog.show(MainActivity.this, "请等待...", "正在为你登录", true); new Thread() { public void run() { try { sleep(); }catch(Exception e) { e.printStackTrace(); }finally { myDialog.dismiss(); } } }.start(); } }).setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub MainActivity.this.finish(); } }).create(); dlg.show(); } }).setNeutralButton("退出", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub MainActivity.this.finish(); } }).create(); dialog.show(); }}xml文件<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@id/username" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="dip" android:layout_marginRight="dip" android:text="账号" android:gravity="left" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText android:id="@id/myusername" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_marginLeft="dip" android:layout_marginRight="dip" android:scrollHorizontally="true" android:autoText="false" android:capitalize="none" android:gravity="fill_horizontal" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:id="@id/password" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="dip" android:layout_marginRight="dip" android:text="密码" android:gravity="left" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText android:id="@id/mypassword" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="dip" android:layout_marginRight="dip" android:scrollHorizontally="true" android:autoText="false" android:capitalize="none" android:gravity="fill_horizontal" android:password="true" /></LinearLayout>
学习android之Service 学习android之Service综述Service是android系统中的一种组件,它跟Activity的级别差不多,但是他不能自己运行,只能后台运行,并且可以和其他组件进行交互
Android学习之BroadcastReceiver总结 Android学习之BroadcastReceiver总结代码下载:
android学习之选择媒体库中的图片 从媒体库中选择图片主要是启动系统相关ActivityIntenti=newIntent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;startActivityForResult(i,RESULT_LOAD_IM
标签: andriod 控件
本文链接地址:https://www.jiuchutong.com/biancheng/368653.html 转载请保留说明!友情链接: 武汉网站建设