- 博客(36)
- 收藏
- 关注
原创 安卓开源库ButterKnife的基本使用
1.在gradle(module)里加上dependencies { compile 'com.jakewharton:butterknife:8.2.1' apt 'com.jakewharton:butterknife-compiler:8.2.1'}2. 基本使用11)替换对象public void bind(ExampleActivit
2016-08-29 21:03:00 584
原创 调用手机里其他应用分享链接,图片
1.分享链接 private void shareTextUrl() { Intent share = new Intent(android.content.Intent.ACTION_SEND); share.setType("text/plain"); share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHE
2016-08-23 15:59:36 859
原创 自定义ActionBar View
1.布局文件<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:
2016-08-19 21:31:04 568
原创 ToolBar的基本使用
1.在styles.xml里修改为:2.对toolbar设定private void setToolBar(){ setSupportActionBar(toolbar); //toolbar.setTitle("用户");不起作用! getSupportActionBar().setTitle("用户"); toolba
2016-08-18 17:25:08 565
原创 实现可点击的背景效果
1.首先在/res/drawable 下,建立文件: 2.在引用时1)直接:android:background="@drawable/selector_default_press"2)在/res/values/styles 里:创建新的style,可方便多处引用 10dp true @d
2016-08-18 08:35:42 588
原创 ViewPager结合自定义View产生滑动pager下方有效圆点变动显示的效果
1.布局文件<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
2016-08-17 08:58:36 823
原创 构造方法的使用注意
public ClumsyIndicator(Context context) { //调用下面两个参数的构造函数,注意是this this(context,null); } public ClumsyIndicator(Context context, AttributeSet attrs) { //调用下面三个参数的构造函数
2016-08-17 08:31:14 556
转载 ANDROID STAGGEREDGRIDLAYOUTMANAGER EXAMPLE TUTORIAL
ANDROID STAGGEREDGRIDLAYOUTMANAGER EXAMPLE TUTORIALIn this tutorial we are going to learn how to create a simple android application that demonstrate the use of android StaggeredGridLayoutMa
2016-08-16 09:11:06 701
原创 PagerSlidingTabStrip与ViewPager
PagerSlidingTabStrip与ViewPager结合使用可以产生下面这种效果1.布局文件<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:l
2016-08-15 11:26:16 475
原创 android 设置 全屏显示 以及 设置屏幕横屏显示
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager .LayoutParams.FLAG_FULLSCREEN); requestWindowFeature(Window.FEATURE_NO_TITLE);//必须在setContentView前设
2016-08-15 11:04:14 1459
原创 onSaveInstanceState 的基本使用
1.//保存imgPager(PagerView)状态 @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt("pager_current_item",pagerImages.g
2016-08-15 09:55:39 942
原创 SwipeRefreshLayout 的基本使用
SwipeRefreshLayout 可以实现下拉刷新的动作效果,加载内容的时候是很有必要使用的1.在布局文件<android.support.v4.widget.SwipeRefreshLayout android:id="@+id/sr_layout" android:layout_width="match_parent" android
2016-08-15 09:39:57 436
原创 在layout里添加分割线
1.首先在/res/values/styles.xml添加: match_parent 1dp @color/light_grey 2.在布局文件里需要添加分割线的地方<View style="@style/HorizonTalDivider"/>
2016-08-14 16:00:34 1571
原创 安卓开源库Picasso的基本使用
Picasso是安卓加载,下载图片的强有力工具1.首先在,build.gradule(Module)里添加dependencies { compile 'com.squareup.picasso:picasso:2.5.2'}2.再同步3.基本使用方式:1)改变图片的大小,减少内存占用Picasso.with(context) .load
2016-08-14 11:46:10 674
原创 在layout里内嵌layout
使用<include android:layout_width="fill_parent" android:layout_height="wrap_content" layout="@layout/yourlayout" />
2016-08-14 10:07:13 616
原创 往github的readme里上传图片
首先,从upload files上传图片到GitHub。再复制该图片的url打开README文件,编辑,在需要插入图片的地方,写入:![Image text](https://raw.github.com/yourName/repositpry/master/yourprojectName/img-folder/test.jpg)最后保存。
2016-08-12 17:05:15 443
转载 android 使用 git上传文件到github
While the EGit plugin for Eclipse is a good option, an even better one would be to learn to use git bash -- i.e., git from the command line. It isn't terribly difficult to learn the very basics of git
2016-08-12 16:39:13 677
原创 android 从手机自带图库选取图片作为应用背景图
1.用intent打开系统图库Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); startActivityForResult(intent, 0001);2.选取图片后,获取返回的图片数据@Override protected void onActivityR
2016-08-12 15:25:17 4183 1
原创 android 设置壁纸基本方法
WallpaperManager wManager = WallpaperManager.getInstance(getApplicationContext());try { wManager.setBitmap(BitmapFactory.decodeFile(imagePath));} catch (IOException e) { e.printStackTrace();
2016-08-12 12:29:30 1346
原创 android 闹钟的简单实现
private AlarmManager am; private Intent alarmIntent; private PendingIntent alarm_pi; private MediaPlayer mp; am = (AlarmManager) getSystemService(ALARM_SERVIC
2016-08-12 11:31:51 1044 1
原创 android 设置 透明的activity
在AndroidManifest里:<activity android:name="com.example.an_hour.AlarmDialog" android:launchMode="singleInstance" android:theme="@android:style/Theme.Translucent">
2016-08-12 10:55:40 412
原创 MediaPlayer 播放 MP3文件的简单使用
1.音频文件在/res/raw目录下MediaPlayer mediaPlayer = MediaPlayer.create(context, R.raw.sound_file_1);mediaPlayer.start(); // 不需要再使用prepare(),在create()里已经包含了2.音频文件在本地目录下Uri myUri = ....; //初始化urlMediaPl
2016-08-12 09:52:20 1349
原创 android 返回键的监听
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { Intent intent = new Intent(this,MainActivity.class); startActivity(intent);
2016-08-12 09:21:03 248
原创 android 添加 notification
1.定义notificationprivate NotificationCompat.Builder mBuilder;mBuilder = new NotificationCompat.Builder(MainActivity.this) .setSmallIcon(R.drawable.a) .setContentTitle("") .setContent
2016-08-10 16:03:53 269
原创 android switch 的基本使用方法
1.xml文件<Switch android:id="@+id/notificate_sw" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" andro
2016-08-10 07:40:58 5931
转载 android 从 service 获取数据 到 activity
package com.websmithing.broadcasttest;import java.util.Date;import android.app.Service;import android.content.Intent;import android.os.Handler;import android.os.IBinder;import android.util.Log
2016-08-09 22:35:54 4670 1
转载 android app 使用 eclipse 更换图标
Go into your AndroidManifest.xml fileClick on the Application TabFind the Text Box Labelled "Icon"Then click the "Browse" button at the end of the text boxClick the Button Labelled: "Create New
2016-08-09 22:08:47 3401
转载 android 应用开机自启的设置方法
Step1: set the permission in AndroidManifest.xmlStep2:Add this is intent filter in receiver Step3:Now you can start your application's first activity from onReceive method o
2016-08-09 15:56:33 1369
转载 android 使手机震动的方法
1.最简单的方式// Get instance of Vibrator from current ContextVibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);// Vibrate for 400 millisecondsv.vibrate(400);2.vibrate(long[] pattern,
2016-08-09 15:04:33 2793
转载 android 拍摄视频的简单demo(来自google官方文档)
原文:https://developer.android.com/guide/topics/media/camera.html#capture-videopackage com.example.video_sample;import java.io.File;import java.io.IOException;import java.text.SimpleDateFormat;
2016-08-05 16:51:46 2709
转载 设置以时间命名的文件路径及名称
private String getOutputMediaPath() { java.util.Date date = new java.util.Date(); String timeTemp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(date.getTime()); //File st
2016-08-03 15:27:53 1069
转载 简单的安卓video recording 以及实时播放(来自:https://developer.android.com/training/camera/videobasics.html#TaskV)
Request Camera PermissionTo advertise that your application depends on having a camera, put a tag in the manifest file: ... > android:name="android.hardware.camera" androi
2016-08-02 21:47:17 2450
转载 android 检测有无网络若没有toast提醒
public class Utility { public static boolean checkNetworkConnection(Context context) { ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE)
2016-08-01 22:08:38 571
转载 在ActionBar中,即便设置showAsAction="always",items仍然在overflow中显示的问题(原文:http://www.cnblogs.com/izhanjun/p/)
今天很是苦恼,明明设置了android:showAsAction="always",但是所有的items全部都显示在overflow中,然后在官网发现了答案。如果你为了兼容 Android 2.1 的版本使用了 Support 库,在 android 命名空间下showAsAction 属性是不可用的。Support 库会提供替代它的属性,你必须声明自己的 XML 命名空间,并且使用该命名空间
2016-08-01 22:03:00 511
转载 尴尬的app:layout_scrollFlags="scroll|enterAlways" 配合NavigationDrawer
昨天想到了NavigationDrawer中Item点击的问题。点击Drawer中的一个Item需要到一个新的页面,你是应该打开一个新的Activity呢还是直接用fragment呢?如果打开新的activity,那么新的Activity覆盖,Drawer按钮就会消失;当然你也可以在新的Activity上加同样的NavigationDrawer,但是那样太浪费资源了。但如果你用frag
2016-08-01 21:42:46 1116
转载 java Calendar的使用方法
YEAR 这是哪年MONTH 这是月(从0开始)WEEK_OF_YEAR 今年的第几星期WEEK_OF_MONTH 这个月的第几星期(从一开始)DATE 今天几号DAY_OF_MONTH 这个月的第几天DAY_OF_YEAR 这一年的第几天DAY_OF_WEEK 这周周几(从日开始计算,从1计算)DAY_OF_WEEK_IN_MONTH 第几周(从第
2016-08-01 20:00:02 1320
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人