Skip to content

Instantly share code, notes, and snippets.

@z8888q
z8888q / gist:3950635
Created October 25, 2012 05:43
Android Control Hardware Acceleration (硬件加速)
http://stackoverflow.com/questions/8895677/work-around-canvas-clippath-that-is-not-supported-in-android-any-more
http://developer.android.com/guide/topics/graphics/hardware-accel.html
硬件加速不支持的操作
When hardware accelerated, the 2D rendering pipeline supports the most commonly used Canvas drawing operations as well as many less-used operations. All of the drawing operations that are used to render applications that ship with Android, default widgets and layouts, and common advanced visual effects such as reflections and tiled textures are supported. The following list describes known operations that are not supported with hardware acceleration:
Canvas
clipPath()
@z8888q
z8888q / gist:2779858
Created May 24, 2012 06:44
Android-防止EditText自动获得焦点
在onCreate中加入
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
这样的话,默认不弹出,点击EditText的时候还会弹出。
@z8888q
z8888q / rails_test_box_prepackaged.sh
Created May 5, 2012 09:47 — forked from jeroenvandijk/rails_test_box_prepackaged.sh
Instructions for setting up the prepackaged Rails test environment
# These commands will help you setup the Rails test environment without problems
#
# MAKE SURE YOU HAVE VIRTUAL BOX INSTALLED http://www.virtualbox.org/wiki/Downloads
#
# Copy paste all of following commands in your normal terminal and the following things will happen:
# - rails_test_box dir is created
# - rails master branch is checkout in the dir rails
# - A Gemfile is created and all the gems to run the virtualbox are installed using bundler
# - The rails vagrant box is downloaded and added to your vagrant boxes
# - A Vagrantfile is created for vagrant
@z8888q
z8888q / gist:2593576
Created May 4, 2012 09:28
Extending the Android Application class and dealing with Singleton
package com.devahead.extendingandroidapplication;
import android.app.Application;
public class MyApplication extends Application
{
@Override
public void onCreate()
{
super.onCreate();
@z8888q
z8888q / gist:2516661
Created April 28, 2012 06:58
how to remove a rule in layoutparams in Android
You can't remove a rule because all rules are always stored in a fixed-size java array. But you can set a rule to 0. For example
layoutParams.addRule(RelativeLayout.RIGHT_OF, 0);
layoutParams.addRule(RelativeLayout.BELOW, R.id.new_ref_LinearLayout);
@z8888q
z8888q / gist:2364264
Created April 12, 2012 02:07
Android获取打开各种文件Intent汇总
//android获取一个用于打开文本文件的intent
public static Intent getTextFileIntent( String param, boolean paramBoolean)
{
Intent intent = new Intent("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (paramBoolean)
{
Uri uri1 = Uri.parse(param );
intent.setDataAndType(uri1, "text/plain");
@z8888q
z8888q / gist:2364151
Created April 12, 2012 01:46
Android 图片上传,包括从相册选取与拍照上传
// 拍照上传
private OnClickListener mUploadClickListener = new OnClickListener() {
public void onClick(View v) {
// 调用相机
Intent mIntent = new Intent("android.media.action.IMAGE_CAPTURE");
@z8888q
z8888q / gist:2364131
Created April 12, 2012 01:37
Android 设置壁纸
package com.example.android.apis.app;
// Need the following import to get access to the app resources, since this
// class is in a sub-package.
import com.example.android.apis.R;
import java.io.IOException;
import android.app.Activity;
@z8888q
z8888q / gist:2273804
Created April 1, 2012 08:56
字节码加载
参照网上其他童鞋的例子与介绍,修改了一下:
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import javax.tools.JavaCompiler;
import javax.tools.JavaCompiler.CompilationTask;
import javax.tools.JavaFileObject;
@z8888q
z8888q / posts_and_comments.rb
Created March 30, 2012 17:27 — forked from vsavkin/posts_and_comments.rb
Create Posts and Comments
blog = Blog.create
post = blog.make_post text: 'great post', location_country: 'Canada', location_city: 'Toronto'
post.make_comment text: 'great comment', location_country: 'Canada', location_city: 'Toronto'