自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(41)
  • 收藏
  • 关注

原创 更改Tab下划线的宽度

通过反射更改下划线的宽度public static void setIndicator(final TabLayout tabLayout){ tabLayout.post(new Runnable() { @Override public void run() { try { //拿到tabL

2017-12-09 21:05:14 3585

原创 ViewPager的简单使用

使用ViewPager需要适配器,分为两种:PagerAdapter和FragmentPagerAdapter1.PagerAdapter:必须实现的四个方法://返回要滑动的View的个数@Overridepublic int getCount() { return mList.size();}//判断当前view与key是否相同@Overridepubl

2017-12-09 21:05:00 217

原创 ScrollView与ListView 的滑动冲突

当scrollView中要嵌套ListView时,需要重写ListView的onMeasure()方法:@Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_V

2017-12-09 21:04:42 256

原创 ViewPager圆形指示器

导入依赖:compile 'me.relex:circleindicator:1.2.2@aar'使用:CircleIndicator circleIndicator;//绑定IDcircleIndicator = (CircleIndicator)findViewById(R.id.activity_strategy_indicator);//绑定ViewPager

2017-12-08 22:09:27 350

原创 Banner 轮播图

导入依赖:compile 'com.youth.banner:banner:1.4.9'初始化:Banner banner = (Banner) view.findViewById(R.id.fragment_home_banner);//图片加载器banner.setImageLoader(new GlideImageLoader());//图片集合banner.

2017-12-08 22:08:34 255

原创 图片旋转

使用://degree 获取旋转的角度 //path 图片路径int degree = ImageUtils.readPictureDegree(path);Bitmap bitmap = BitmapFactory.decodeFile(path,bitmapOptions);//旋转图片操作bitmap = ImageUtils.rotaingImageView(degre

2017-12-08 22:06:01 155

原创 动画的使用

属性动画的运行机制是通过不断地对值进行操作来实现的。ValueAnimator:动画机制中的核心类,初始值和结束值之间的动画过渡是由这个类负责的。使用:ObjectAnimator:可以对任意对象的任意属性进行动画操作。使用:只要对象中有setXXX() 和 getXXX

2017-12-08 22:01:25 174

原创 定时任务

定时任务有三种:1.TimerTask2.AlarmManager3.CountDownTimer1.TimerTask:TimerTask task= new TimerTask() { @Override public void run() { count++; Log.i("M

2017-12-08 21:50:02 145

原创 图片压缩

1. 像素压缩BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();//缩放图片bitmapOptions.inSampleSize = 8;Bitmap bitmap = BitmapFactory.decodeFile(path,bitmapOptions);2. 质量压缩ByteArrayOu

2017-12-08 21:47:59 129

原创 手机摇一摇功能

/** * 工具类,实现监测摇一摇 **/public class ShakeUtil implements SensorEventListener { private SensorManager mSensorManager = null; private OnShakeListener mOnShakeListener = null; //重力加速度

2017-12-08 21:46:19 335

原创 二维码的使用

导入依赖:compile 'cn.yipianfengye.android:zxing-library:2.1'添加权限:1.先在Application中进行初始化:ZXingLibrary.initDisplayOpinion(this);2.扫描二维码:Intent intent = new Intent(getA

2017-12-08 21:39:09 170

原创 状态栏的使用

沉浸模式:游戏和爱奇艺电影Android 4.4 及以上可以实现状态栏透明:Android 5.0及以上才可以使用隐藏底部导航栏:View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION隐藏顶部导航栏:View.SYSTEM_UI_FLAG_LAYOUT_STAB

2017-12-08 21:37:53 233

原创 软键盘弹出时顶起上方布局

在指定activity中,添加 android:windowSoftInputMode="adjustPan|stateHidden",上方布局将不会上移,而是软键盘会覆盖上方布局。

2017-12-08 21:32:41 392

原创 获取手机内的所有应用列表

获取手机内所有应用信息

2017-10-13 19:54:15 2040

原创 HttpClient

packagingOptions { exclude 'META-INF/NOTICE' // will not include NOTICE file exclude 'META-INF/LICENSE' // will not include LICENSE file // as noted by @Vishnuvathsan you may a

2017-04-06 13:27:03 383

原创 RelativeLayout 居中

在RelativeLayout的子空间中 加上: android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_centerInParent="true"

2017-03-27 21:47:03 455

原创 Layout_weight的含义

android:layout_weight的真实含义是:一旦View设置了该属性(仅在LinearLayout中有效),那么该 View的宽度等于原有宽度(android:layout_width)加上剩余空间的占比。Google官方推荐,当使用weight属性时,将width设为0dip即可,效果跟设成wrap_content是一样的。这样weight就可以理解为占比了!

2017-03-20 15:20:20 526

原创 catalan数

卡塔兰数的一般公式为 C(n,2n)/(n+1)。性质:令h(0)=1,h(1)=1,卡塔兰数数满足递归式:h(n)= h(0)*h(n-1) + h(1)*h(n-2) + ... + h(n-1)h(0) (其中n>=2),这是n阶递推关系;还可以化简为1阶递推关系: 如h(n)=(4n-2)/(n+1)*h(n-1)(n>1) h(0)=1该递推关系的解为:h(n)=C(2n

2016-04-15 12:57:54 360

原创 dijkstra算法--求两点之的最短路径

# include # define MAX 20int creat_cost(int cost[][MAX]) //cost 用来表示图的邻接矩阵 { int arcnum,vexnum,v1,v2,w; printf ("请输入顶点个数和弧数\n"); //输入图的顶点数和弧数 scanf ("%d %d",&vexnum,&arcnum); for (int i=1;

2016-04-13 14:38:53 912

原创 BFS--点到点间的最短路径

# include # include # include # define MAX 20 //最大顶点数 typedef struct ARCNODE{ int num; //该边所指的顶点的位置 struct ARCNODE * next; //指向下一条边的指针 }arcnode; //表的结点 typedef struct Vnode{ char d

2016-04-12 14:32:51 1156

原创 DFS--图中两点之间的路径

# include # include # include # define MAX 20 //最大顶点数 typedef struct VNODE{ int num; //该边所指的顶点的位置 struct VNODE *next; //指向下一条边的指针 }arcnode; //表的结点 typedef struct LIST{ char data;

2016-04-11 21:50:38 2145 1

原创 BFS--广度优先搜索--图的邻接表

# include # include # include # define MAX 20 //顶点最大值 typedef struct ARCNODE{ int num; //该边所指的顶点的位置 struct ARCNODE *next; //指向下一条边的指针 }arcnode; //表的结点 typedef struct VNODE{ char

2016-04-11 21:38:47 474

原创 BFS-图的广度优先搜索--邻接矩阵

# include # include # include # define MAX 20 //最大顶点数 typedef struct{ char vexs[MAX]; //顶点向量 bool visited[MAX]; //访问标志数组 int arcs[MAX][MAX]; //邻接矩阵 int arcnum,vexnum; //图的当前顶点数和弧数

2016-04-11 21:30:20 567

原创 DFS--深度优先搜索--图的邻接表表示

# include # include # include # include # define ok 1# define NULL 0# define MAX 20 //最大顶点数 typedef struct ARCNODE{ int adjvex; //该边所指的顶点的位置 struct ARCNODE * next; //指向下一条边的指针 // i

2016-04-06 20:59:20 437

原创 DFS--深度优先搜索--图的邻接矩阵

# include # include # include # define MAX 10 //最大顶点数 typedef struct { char vexs[MAX]; //顶点 向量 bool visited[MAX]; //访问标志数组 int arcs[MAX][MAX]; //邻接矩阵 int arcnum,vexnum; //图的当前结

2016-04-06 14:18:37 669

原创 图的邻接表表示

#include using namespace std;#include #include #define OK 1#define NULL 0#define MAX_VERTEX_NUM 20 // 最大顶点数typedef char VertexType;typedef int VRType;typedef int InforType;typedef struct

2016-04-05 22:27:46 416

原创 图的邻接矩阵表示

# include # include # include # define MAX 10 //最大顶点数 typedef struct{ char vexs[MAX]; //顶点向量 int arcs[MAX][MAX]; //邻接矩阵 int vexnum,arcnum; //图的当前点数和弧数 }MGRAPH,* mgraph;void init_mgra

2016-04-05 22:01:07 620

原创 二叉树--链表实现

# include # include typedef struct TREE{ char data; struct TREE * lchild; struct TREE * rchild;}Tree, * ptree;void init_tree(ptree &root); //初始化二叉树 void creat_tree(ptree &root); //创建二叉树

2016-04-03 15:33:18 2200

原创 归并排序

归并排序:利用"归并"技术来进行排序。归并是指将若干个已排序的子文件合并成一个有序的文件。可以用于外排序。# include void merge_sort(int a[],int b[],int low,int high);void merge(int a[],int b[],int low,int mid,int high);int main(void){ int a[]

2016-04-02 19:30:04 414

原创 希尔排序

希尔排序:先取一个小于n的整数d1作为第一个增量,把文件的全部记录分成d1个组。所有距离为dl的倍数的记录放在同一个组中。先在各组内进行直接插人排序;然后,取第二个增量d2    最后一遍的增量必须是1,其实是就是调用直接插入排序算法。# include void shell_sort(int a[],int len);void shell_insert(int a[],int

2016-04-02 18:42:02 329

原创 直接插入排序

直接插入排序:每次将一个待排序的记录,按其关键字大小插入到前面已经排好序的子文件中的适当位置,直到全部记录插入完成为止。当数组已经排好序,直接插入排序的时间复杂度为O(n)# include void insert_sort(int a[],int len);int main(void){ int a[]={165,416,51,654,351,6541,3241,654,3,

2016-04-02 18:22:39 295

原创 堆排序

堆排序:根据输入数据,利用堆的调整算法形成初始堆,然后交换根元素与尾元素,总的元素个数减1,然后从根往下调整。堆排序的最好、最坏、平均时间复杂度都为O(nlogn)# include void heap_adjust(int a[],int i,int len);void heap_sort(int a[],int len);int main (void){ int a[]={1

2016-04-02 18:09:38 365

原创 直接选择排序

直接选择排序:每一趟从待排序的记录中选出关键字最小的记录,顺序放在已排好序的子文件的最后,直到全部记录排序完毕。# include void select_sort(int a[],int len);int main (void){ int a[]={1,3,5,8,634,64,3,16,46,1,63}; select_sort(a,sizeof(a)/sizeof(

2016-04-02 09:43:27 380

原创 冒泡排序

冒泡排序:两两比较待排序记录的关键字,发现两个记录的次序相反时即进行交换,直到没有反序的记录为止。# include void msort(int a[],int n);int main (void){ int a[]={1,2,3,564,48,412,55465,463,164,}; msort(a,(sizeof(a)/sizeof(a[0]))); for (i

2016-04-02 09:31:33 346

原创 快速排序

快速排序:# include void qsort(int a[],int low,int hight);int main (void){ int i; int a[]={1,5,3,9,7,5,6,2,48,646,65}; qsort(a,0,sizeof(a)/sizeof(a[0])-1); //sizeof(a)/sizeof(a[0])-1 表示数组的长度 f

2016-04-02 09:24:01 341

原创 约瑟夫环--链表实现

# include # include //# define n 21//# define m 3typedef struct Node{ int data; struct Node * next;}NODE,*pnode;typedef struct linklist{ pnode phead; pnode ptail; int len;}LINK,*plink;

2016-04-01 15:03:08 502

原创 栈——链表实现

# include # include # include typedef struct NODE // 创建结点的结构体 { int data; struct NODE *next;}node,*pnode;typedef struct STRACK //创建头指针和尾指针的结构体 { pnode ptop; pnode

2016-04-01 13:23:12 485

原创 链表的基本操作

# include # include struct list{ int num; struct list * next;};typedef struct list node;typedef node * link;void printlist(link head); //输出 链表 link creatlist(int

2016-04-01 13:22:24 397

原创 链表——数组实现

# include # include # include typedef struct ARR{ int * pbase; //数据域 int len; //数组长度 int cnt; //有效个数 }Arr,*parr;void init(parr arr,int lengh); //创建数组 bool

2016-04-01 13:21:42 411

原创 循环队列--数组实现

# include # include # define len 6 //队列长度 typedef struct QUENE { int * pbase; //数据域 int front; //头指针 int rear; //尾指针 }Quene,* quene;vo

2016-04-01 13:20:12 512

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除