![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
android
JimmyLegend
Write the Code Change the World!
展开
-
监听菜单列表点击事件
menu:<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context="com.example.optionsmenu.MainActivity" > <item a原创 2016-07-17 16:54:01 · 2168 阅读 · 0 评论 -
视线抽屉样式效果
main.xml主布局文件文件:<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/container"> <Grid原创 2016-08-27 21:30:35 · 678 阅读 · 0 评论 -
四大组件之BroadcastReceiver
组件篇BroadcastReceiver:普通广播的特点:同级别接收是随机的(无序的)级别低的后收到广播接收器不能截断广播的继续传播也不能处理广播同级别动态注册高于静态注册package com.example.broadcastrecieverdemo;import android.app.Activity;import android.content.Intent原创 2016-09-09 17:37:51 · 180 阅读 · 0 评论 -
Service
Start方式的特点:服务跟启动源没有任何联系无法的带服务对象Bind方式的特点:通过Ibinder接口实例,返回一个ServiceConnection对象给启动源通过ServiceConnection对象的相关方法可以得到Service对象package com.example.servicedemo;import com.example.servicedemo.My原创 2016-09-10 22:02:03 · 283 阅读 · 0 评论 -
布局填充的另一种方法
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LayoutInflater inflater =(LayoutInflater) MainActivity.this.getSystemService(LAYOUT_INFLATER_SE原创 2016-09-11 09:44:10 · 277 阅读 · 0 评论 -
Android中常用的系统服务
package com.example.systemservicedemo;import android.app.Activity;import android.app.ActivityManager;import android.content.Context;import android.media.AudioManager;import android.net.Connectiv原创 2016-09-11 19:14:45 · 346 阅读 · 0 评论 -
使用GestrueDetector进行手势识别
手势交互过程原理:1、手触屏的一刹那触发MotionEvent事件。2、被OnTouchListener监听,在onTouch中获得MotionEvent对象。3、GestrueDetector转发MotionEvent对象至OnGestureListener。4、OnGestureListener获得该对象,根据该对象封装的信息做出合适的反馈。MotionEvent:1、原创 2016-09-12 18:02:29 · 978 阅读 · 0 评论 -
存取用户名实例
xml文件:<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height=原创 2016-09-04 17:16:44 · 285 阅读 · 0 评论 -
编写SQL语句操作数据库
代码:package com.example.sqlitedemo;import android.app.Activity;import android.database.Cursor;import android.database.sqlite.SQLiteDatabase;import android.os.Bundle;import android.util.Log;imp原创 2016-09-04 20:31:15 · 329 阅读 · 0 评论 -
使用内置函数操作数据库
package com.example.sqlitedemo2;import android.app.Activity;import android.content.ContentValues;import android.database.Cursor;import android.database.sqlite.SQLiteDatabase;import android.os.Bu原创 2016-09-04 21:32:54 · 373 阅读 · 0 评论 -
SQLiteOpenHelper
package com.example.sqlitedemo3;import android.app.Activity;import android.database.Cursor;import android.database.sqlite.SQLiteDatabase;import android.os.Bundle;import android.util.Log;import原创 2016-09-04 22:05:46 · 333 阅读 · 0 评论 -
加载手机磁盘中的文件
xml文件: <AbsoluteLayout android:id="@+id/layout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/white" xmlns:android="http原创 2016-08-27 17:05:30 · 462 阅读 · 0 评论 -
使用ListAcyivity实现动态菜单列表
如果想让自己办写的程序继承与ListActivity,可用过下列方法来实现:getSelectItemId():获取当前Key所选择的Item ID。onContentChanged():ListActivity列表内容更新事件。onRestoreInstanceState(Bundle):还原至此实例初始状态事件。setListAdapter(ListAdapter):设置Lis原创 2016-08-27 16:16:28 · 470 阅读 · 0 评论 -
动态添加菜单项
package com.example.optionsmenu;import android.app.Activity;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.widget.Toast;public class MainActivit原创 2016-07-17 17:02:21 · 465 阅读 · 0 评论 -
动态添加菜单栏Pluse
package com.example.optionsmenu;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.widget.To原创 2016-07-17 17:16:52 · 252 阅读 · 0 评论 -
Android学习路线
第一阶段:Java面向对象编程1.Java基本数据类型与表达式,分支循环。 2.String和StringBuffer的使用、正则表达式。 3.面向对象的抽象,封装,继承,多态,类与对象,对象初始化和回收;构造函数、this关键字、方法和方法的参数传递过程、static关键字、内部类,Java的垃极回收机制,Javadoc介绍。 4.对象实例化过程、方法的覆盖、final关键字转载 2016-06-20 19:36:52 · 271 阅读 · 0 评论 -
ContextMenu菜单
创建ContexMenu菜单方法一:布局:<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" andro原创 2016-07-18 16:56:38 · 309 阅读 · 0 评论 -
动态添加SubMenu子菜单
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.submenu" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdk原创 2016-07-18 19:31:04 · 1263 阅读 · 0 评论 -
使用XML添加SubMenu子菜单
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.submenu" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdk原创 2016-07-18 19:50:15 · 481 阅读 · 0 评论 -
Toast的常用方法
Toast的常用方法:Toast toast=new Toast(context); Toast.makeText(context, text, duration);//返回值为Toast toast.setDuration(duration);//设置持续时间 toast.setGravity(gravity, xOffset, yOffset原创 2016-07-08 22:56:19 · 2236 阅读 · 0 评论 -
androidManifest
androidManifest.xml配置文件介绍:本质:androidManifest.xml是整个应用的主配置清单文件。包含:该应用的包名、版本号、组件、权限等信息。作用:记录该应用的相关的配置信息。androidManifest.xml常用标签解读:全局篇:包名、版本信息。组件篇:四大组件。(Activity、Service、Broadcast Recei原创 2016-07-19 20:44:16 · 233 阅读 · 0 评论 -
联合使用DatePIcker和TimePicker来选择日期和时间
TimePicker中的主要方法:setCurrentMinute(Integer currentMinute):设置当前时间的分钟。getCurrentMinute():获取当前时间的分钟。setEnabled(boolean enabled):设置当前视图是否可以编辑。setOnTimeChangeListener(TimePicker.OnTimeChangeListener原创 2016-08-27 11:21:58 · 722 阅读 · 0 评论 -
动态分割手机屏幕
xml文件:<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="@drawable/white" android:orientation="vertical" android:layout_width="fill_parent" andro原创 2016-08-27 11:33:09 · 608 阅读 · 0 评论 -
HttpUrlConnection
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_p原创 2016-09-18 10:32:32 · 287 阅读 · 0 评论 -
在Android中创建文件
package com.example.filedemo1;import java.io.File;import java.io.IOException;import android.app.Activity;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import...原创 2016-09-05 20:37:31 · 14279 阅读 · 0 评论 -
在Android中对文件的读写操作
package com.example.filedemo2;import java.io.ByteArrayOutputStream;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;原创 2016-09-06 21:09:19 · 2545 阅读 · 0 评论 -
android 相对布局属性
RelativeLayout布局 android:layout_marginTop="25dip" //顶部距离 android:gravity="left" //空间布局位置 android:layout_marginLeft="15dip //距离左边距 // 相对于给定ID控件 android:layout_above 将该控件的底部置于给定ID的控件之上;转载 2016-10-25 22:15:01 · 361 阅读 · 0 评论 -
使用ListView显示信息列表
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <I原创 2016-09-29 20:55:08 · 369 阅读 · 0 评论 -
Spinner的简单使用
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_p原创 2016-10-26 20:35:12 · 263 阅读 · 0 评论 -
安卓在xml文件(布局文件)中做一些细微改变却运行程序报错的原因
我们有时在xml布局文件中做了一些细微的变化,语法上没有任何问题,但是运行程序的时候却报错或者是运行效果并不是写xml文件应该显示的效果,那么这是什么原因呢?症状:比如说只是在线性布局中把两个控件的位置交换了一下顺理成章,不应该出现任何问题,但是却运行报错。原因:出现这个问题其实是因为自己开始的时候·1写了或者直接拖拽了两个控件,这时在Android编译环境的R文件中已经生成了对应转载 2016-10-27 20:25:19 · 1656 阅读 · 0 评论 -
ProgressBar的简单使用
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_p原创 2016-10-27 20:43:36 · 267 阅读 · 0 评论 -
WebView的简单使用
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_p原创 2016-10-28 18:10:06 · 255 阅读 · 0 评论 -
android studio 中去除应用标题栏
㈠ ⒈ mainifests中设置: android:theme="@style/AppTheme"(即默认设置). ⒉ values->styles.xml中设置: style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar".㈡ values->styles.xml中: 在当先使用的sty转载 2016-10-31 19:40:14 · 465 阅读 · 0 评论 -
Android--获取当前系统时间
import java.text.SimpleDateFormat; SimpleDateFormat formatter = new SimpleDateFormat ("yyyy年MM月dd日 HH:mm:ss "); Date curDate = new Date(System.currentTimeMillis());//获取当前时间 String str = forma转载 2016-10-31 19:51:53 · 783 阅读 · 0 评论 -
android 实时显示系统时间
我们知道,用System.currentTimeMillis()可以获取系统当前的时间,我们可以开启一个线程,然后通过handler发消息,来实时的更新TextView上显示的系统时间。 我们开启一个线程,线程每隔一秒发送一次消息,我们在消息中更新TextView上显示的时间就ok了。 首先我们在布局文件中放一个TextView用来显示时间,如下所示: LinearL转载 2016-10-31 12:49:07 · 9937 阅读 · 4 评论 -
适配器Adapter
Android之Adapter用法总结1.概念 Adapter是连接后端数据和前端显示的适配器接口,是数据和UI(View)之间一个重要的纽带。在常见的View(ListView,GridView)等地方都需要用到Adapter。如下图直观的表达了Data、Adapter、View三者的关系:Android中所有的Adapter一览:转载 2017-03-20 15:20:34 · 312 阅读 · 0 评论 -
使用DatePicker和TimePicker显示当前日期和时间
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_p原创 2016-10-25 21:25:23 · 835 阅读 · 0 评论 -
Spinner样式大全
关于spinner控件有很多特殊的样式甚至是表现的很夸张的样式,这里就仅仅通过更换系统自带的xml样式来试验各种spinner样式效果。首先在工程里创建最简单的spinner:需要更换的地方有两处:一。ArrayAdapter adapter = new ArrayAdapter( this, Android.R.layout.simple_spinner_item);转载 2016-09-28 18:49:08 · 441 阅读 · 0 评论 -
CheckBox复选框
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <C原创 2016-09-19 20:28:28 · 250 阅读 · 0 评论 -
RadioButton单选按钮
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <RadioGr原创 2016-09-19 20:30:24 · 249 阅读 · 0 评论