![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
android
文章平均质量分 65
heinika
没有人生活在过去,也没有人生活在未来。
展开
-
gson的使用细节
title: gson的使用细节 date: 2016-01-24 12:23:39tags: json解析关于json,gson是最常用到的一个库。 平常使用时我通常使用Gson gson = new Gson();的方式创建。 但是最近在使用木哥给的一个volley工具时,出现了解析不出来的情况,很是郁闷。 自己看了半天也没找到原因。所以专门再吧gson的使用方法总结一下。 Gson的原创 2016-01-25 11:35:35 · 817 阅读 · 0 评论 -
获得所有已安装程序的信息
PackageManager类通过getPackageManager()获得abstract ListApplicationInfo>getInstalledApplications(int flags)Return a List of all application packages that are installed on the device.原创 2015-10-03 20:03:12 · 529 阅读 · 0 评论 -
视频(多媒体) MediaPlayer,camera
源码:https://github.com/heinika/MyVideo1,VideoView@Overridepublic void onClick(View v) { switch (v.getId()){ case R.id.button_video_play: videoView.setVideoPath(Environment.getE原创 2015-09-15 22:09:46 · 392 阅读 · 0 评论 -
网络连接2 单线程和多线程下载 并更新progressbar
1,单线程下载 AsyncTask来更新UI case R.id.button_download_single:new DownloadTask().execute();private class DownloadTask extends AsyncTask{@Overrideprotected void onProgressUpdate(Integer..原创 2015-09-12 16:43:04 · 516 阅读 · 0 评论 -
ExpandableListView的箭头问题
通过布局文件修改如果你不想使用默认的箭头指示标志,可以通过修改ExpandableListView的groupIndicator图片实现你自己的效果。通常,我们使用selector来定义这组图片通过代码修改(推荐,比较灵活)先设置xml中的箭头android:groupIndicator=”@null” 在groupitem中定义imageview 再通过baseexpandableviewad原创 2015-08-26 21:54:55 · 737 阅读 · 0 评论 -
网络连接1 查看网络状态和webview
1,查看网络状态首先添加读取网络状态的权限uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />获取NetworkInfo类,得到网络信息NetworkInfo info = manager.getActiveNetworkInfo();if (info != null && info.原创 2015-09-12 16:41:19 · 999 阅读 · 0 评论 -
ViewDragHelper详解,简化拖动操作
没想到还有这么个家伙,简直是滑动必备啊!2013年谷歌i/o大会上介绍了两个新的layout: SlidingPaneLayout和DrawerLayout,现在这俩个类被广泛的运用,其实研究他们的源码你会发现这两个类都运用了ViewDragHelper来处理拖动。ViewDragHelper是framework中不为人知却非常有用的一个工具。ViewDragHelper解决了原创 2015-10-02 10:23:23 · 1219 阅读 · 1 评论 -
仿QQ5.0侧边栏(拖拽,动画)
github源码下载:https://github.com/heinika/MyQQSideBar主要用到了ViewDragHelper这个类来简化拖拽的操作。中间设置了layout缩小和变大,透明度等动画。背景还添加了一个变暗的滤镜。第一步:初始化public DragLayout(Context context, AttributeSet attrs, in原创 2015-10-02 10:57:46 · 884 阅读 · 0 评论 -
volley的正确使用方式
源码下载:https://github.com/heinika/android-volley导入的三种方式:在dependencies下搜索导入源码包,import model 在dependencies导入model导入jar,放在lib目录下networkimageview防止内存溢出先下载,判断内存,不够就压缩图片volley实现方式(如原创 2015-09-14 19:34:34 · 547 阅读 · 0 评论 -
xUtils使用(简化开发,必备)
github地址:https://github.com/wyouflf/xUtils导包:Androidstudio在dependencies下搜索xUtils即可目前xUtils主要有四大模块:DbUtils模块:android中的orm框架,一行代码就可以进行增删改查;支持事务,默认关闭;可通过注解自定义表名,列名,外键,唯一性约束,NOT NULL约束原创 2015-09-14 20:04:01 · 1070 阅读 · 0 评论 -
android存储方式之文件存储
xml存储:sharepreferences 存放在shared_prefs文件夹下case R.id.button_write:/** * 以xml格式存储 */SharedPreferences sharedPreferences = getSharedPreferences("myshare",MODE_PRIVATE)原创 2015-09-07 21:53:46 · 372 阅读 · 0 评论 -
使用git来控制版本 并分享到github上(自学或分享必备)
由于本人是个屌丝,还没用起高大尚mac,所以本篇文章介绍的是基于window系统的As we know,Git是目前世界上最先进的分布式版本控制系统,而Github是最大的开源社区。在Github上的项目就是使用git来管理的,所以学好Git的使用是很有必要的。下面看具体步骤。1、要在as中使用git,首先你的在本地安装Git,具体安装流程大家可以看我blog:版本控制工具Git详转载 2015-09-24 21:11:58 · 791 阅读 · 0 评论 -
android手势事件传递(实例:下拉刷新)
先看看api中的解释分发事件public boolean dispatchTouchEvent (MotionEvent ev) Added in API level 1Pass the touch screen motion event down to the target view, or this view if it原创 2015-09-25 11:02:35 · 1847 阅读 · 0 评论 -
listview的滑动删除框架的使用
效果如图第一步,导入框架框架地址:https://github.com/baoyongzhang/SwipeMenuListView有关其他设置地址中有详细的说明下载后将里面的library导入为module即可第二步,创建刷菜单,并setMenuCreator// step 1. create a MenuCreatorSwipeMenuCreat原创 2015-10-03 21:41:14 · 726 阅读 · 0 评论 -
自定义View
1,自定义时钟public classMyViewextendsView { private int width; private int height; private Paint mPaintLine; private Paint mPaintCircle; private Paint mPaintText; private原创 2015-09-16 23:11:11 · 480 阅读 · 0 评论 -
Uri转化为filepath的方法,及压缩图片的方法
源码地址:https://github.com/heinika/MyCream1,4.4之前Uri转化为filepath的方法public class GetPathFromUriBeforekitkat {private static String filename;private static Cursor cursor;public static String getPath原创 2015-09-16 23:00:34 · 1570 阅读 · 0 评论 -
Android手势操作(双击,长按,滑动,滚动,多点触控)
源码分享:https://github.com/heinika/GestureListener主要使用到GestureDetector 这个类:在实际使用中一般使用他们的子类GestureDetector.SimpleOnGestureListener()下面自定义一个View实现手势操作:public class MyButton extends Button { pr原创 2015-09-24 22:03:33 · 7339 阅读 · 0 评论 -
Android推送服务(使用第三方api需要注意的地方)
常用的推送服务一般有两种,百度和友盟1,先讲百度:下载sdk,然后按照说明文档一步一步来即可:http://push.baidu.com/doc/guide/index在logcat中打印如下,即创建推送成功09-22 19:00:22.204 12004-12004/com.example.zhonghang.mypushdemo D/MyPushMessageRe原创 2015-09-22 20:58:09 · 714 阅读 · 0 评论 -
有关Material Design新特性的详解。
源码地址:https://github.com/chrisbanes/cheesesquare自己添加备注后的地址:https://github.com/heinika/DrawerLayoutDemo英文教程:https://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout中文教程:http://m原创 2015-10-26 20:19:56 · 2513 阅读 · 0 评论 -
仿迅雷下载进度条
效果如下:package com.apple.myview.widget;/** * 模仿迅雷下载的效果*/public class Progress4 extends View {private int width;private int height;private Paint mPaintBackGround;private Paint mPaintWave;private Pa原创 2015-09-18 20:08:31 · 2315 阅读 · 0 评论 -
Gson解析(详解)
先介绍一下Android原生的解析在Android中包含四个与JSON相关的类和一个Exceptions:JSONObject JSONArray JSONStringerJSONTokenerJSONException1,JSONObject {“JSON”: “Hello, World”},key和velu原创 2015-11-08 16:56:44 · 4648 阅读 · 0 评论 -
自定义View3 仿联系人A-Z选择效果
1,自定义Viewpackage com.apple.mybitmap.widget;/** * 联系人A-z的view */public class MyA2ZView extends View {private int width;private int height;private float x;private float y;private int index=-1;privat原创 2015-09-17 22:28:10 · 459 阅读 · 0 评论 -
自定义属性
自定义布局的xml文件format规定属性的类型xml version="1.0" encoding="utf-8"?>resources> declare-styleable name="GuaGuaView"> attr name="guaguaview_background" format="reference">attr> attr name="g原创 2015-09-18 16:01:19 · 470 阅读 · 0 评论 -
自定义View2 刮刮卡效果
效果如下图:这里需要用到上一节中PorterDuffXfermode(把传递改头换面的服务员) xfermode内容请参考http://note.youdao.com/share/?id=3f61125240ed4553df90532d42192ccb&type=note刮刮需要用到的是Xor的效果。刮刮卡的自定义viewpublic cla原创 2015-09-18 19:55:03 · 540 阅读 · 0 评论 -
android HttpClient的使用
虽然已经被Google抛弃,但是介于使用范围比较广,而且xUtils还是基于HttpClient,就再看一眼。case R.id.button_doget:new HttpClientTask().execute();class HttpClientTask extends AsyncTask{@Overrideprotected String doInBackground(S原创 2015-09-14 20:28:13 · 560 阅读 · 0 评论 -
拍摄图片和选取图片
源码地址:https://github.com/heinika/MyCream1,拍摄图片private void useCreame() { Intent intent = new Intent();intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);file = new File(Environment.getExternalStorage原创 2015-09-16 22:58:05 · 507 阅读 · 0 评论 -
自定义View2 ,自定义路径,bitmap图像处理(缩放,翻转之类,还有Matrix和Mode)
自定义时钟,四种进度条,自定义路径,bitmap图像处理(缩放,翻转之类,还有Matrix和Mode),仿联系人A-Z选择效果1,画轨迹/*** 画轨迹*/public class DrawPath extends View {private int width;private int height;private Paint mPaintBackGround;privat原创 2015-09-17 22:25:40 · 652 阅读 · 0 评论 -
音乐(多媒体)SoundPool,MediaRecorder和Mediaplayer
源码地址:https://github.com/heinika/MyMediaPlayerDemo1,先从简单的铃声开始:注意21以后用SoundPool.Builder创建public class MainActivity extends AppCompatActivity {private Button mButtonSoundPlay;private SoundPool so原创 2015-09-15 21:37:07 · 578 阅读 · 3 评论 -
qq聊天界面七:表情的发送接收(用富文本现实)
先预览一下效果先定义一个包含反射的ImageGettter/** * 用于解析富文本中的表情图片 */mImageGetter = new Html.ImageGetter() {@Overridepublic Drawable getDrawable(String source) { Class clazz = R.mipmap.class;try {原创 2015-09-01 20:29:52 · 2754 阅读 · 0 评论 -
AsyncTask详解 并实现实例-模拟下载
API中的内容:简介Class OverviewAsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate t原创 2015-09-09 22:31:33 · 474 阅读 · 0 评论 -
Activity的生命周期
先上周期图 一个activity的绳命顺序:onCreate>onStart>onResume>omPause>onStop>onDesory两个activity的绳命顺序(第一个activity—第二个activity—第一个activity—退出): 运行到onCreat 运行到onStart 运行到onResume 运行到onPause 第二个界面onCreat 第二个界面onS原创 2015-08-18 19:03:02 · 381 阅读 · 0 评论 -
android广播broadcast详解
一、Android广播机制三要素: 1、广播(Broadcast):用于发送广播。是一种广泛应用的在应用间传输信息的机制 2、广播接收器(BroadcastReceiver):用于接收广播。是对发出来的Broadcast进行过滤接受并响应的组件。 3、意图内容(Intent):用于保存广播相关信息的媒介二、广播的功能和特征: 1、广播的生命周期很短,经过 调原创 2015-09-08 20:44:49 · 559 阅读 · 0 评论 -
仿qq聊天界面
上传图片太慢直接上笔记了。。。 http://note.youdao.com/share/?id=bce82795636eec97b7770f48b9752c68&type=notehttp://note.youdao.com/share/?id=f50afb75722e9c294402a927484c3c75&type=notehttp://note.youdao.com/share/?id=2原创 2015-08-31 21:20:46 · 1018 阅读 · 0 评论 -
listview实现自动向上滚动,快速滚动,和滚动条的一些设置
在使用listView显示聊天窗口时,弹出输入法,listview不会自动向上滚动,会遮盖内容,在manifest中的Activity加入:1 android:windowSoftInputMode=”adjustResize” 也无法解决问题。 通过博客,在listview中添加以下三个属性,可行: 继承于view android:scrollbarStyle=”insideInset”原创 2015-08-29 20:49:25 · 3186 阅读 · 0 评论 -
toast和dialog
小属性和要注意的地方: margin:外部离开 padding:内部离开 调试句柄 context application和四大组件toast的作用范围一般是application dialog的作用范围一般是activity 两个组件的显示都需要调用show,dialog还需要creattoast自定义的话用setView方法 一些练习<LinearLayout xmlns:and原创 2015-08-27 20:45:43 · 550 阅读 · 0 评论 -
高仿qq照片选择界面,哈哈
好像也没啥技术含量,回顾一下吧。。。布局文件<Gallery android:id="@+id/mGallery" android:layout_width="match_parent" android:layout_height="match_parent"></Gallery><?xml version="1.0" encoding="utf-8"原创 2015-08-27 20:32:01 · 853 阅读 · 0 评论 -
自定义GridView
自定义GridView与自定义的ListView步骤一致一,定义布局文件<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"原创 2015-08-26 19:29:59 · 446 阅读 · 0 评论 -
自定义ExpandableListView
可扩展的listview,类似于好友分组 已班级和学生为例一,创建ExpandaListView布局,item_class,item_student布局主布局 <ExpandableListView android:id="@+id/mExpandableListView" android:layout_width="match_parent" an原创 2015-08-26 20:28:40 · 451 阅读 · 0 评论 -
AutoCompeteTextView,Spinner和Gallery
这三个控件都可以setadapter,通过继承BaseAdapter都可以实现Item的自定义。AutoCompeteTextView 可以实现对item文本的搜索。<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.co原创 2015-08-26 20:10:17 · 466 阅读 · 0 评论 -
自定义adapter 及其性能优化
基本属性和常见问题先来看看一些基本属性和常见问题。 listview 常用属性 cachecolorhint:缓存默认颜色一般给全透明 android:cacheColorHint=”#00ffffff” divder:分隔线 android:divider=”#000000” android:dividerHeight=”1dp” 改变按下的颜色: item的背景改为drawa原创 2015-08-25 21:05:57 · 663 阅读 · 0 评论