Skip to content

Instantly share code, notes, and snippets.

@jiemachina
jiemachina / gist:3496537
Created August 28, 2012 09:29
start other app
/* start other app in android*/
Intent intent = mPackageManager.getLaunchIntentForPackage(pi.packageName);
mContext.startActivity(intent);
@jiemachina
jiemachina / Adapter Item Descendants
Created August 29, 2012 03:00
屏蔽是item先点击还是listView先点击
android:descendantFocusability="afterDescendants"
android:descendantFocusability="beforeDescendants"
android:descendantFocusability="blocksDescendants"
@jiemachina
jiemachina / MyTextView.java
Created August 29, 2012 03:53
Marquee TextView 跑马灯效果
package jie.ma.china.view;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.TextView;
public class MyTextView extends TextView {
public MyTextView(Context context) {
@jiemachina
jiemachina / eclispe key
Created August 31, 2012 02:41
search file name eclipse key
ctrl + shift + r
@jiemachina
jiemachina / gist:3695896
Created September 11, 2012 04:10
webview中的组件可以编辑,因为mEditText组件已经获得焦点,所以先除去焦点,然后再分配可以有焦点,
mWebView.requestFocus(View.FOCUS_DOWN);
//先是去焦点,然后再给焦点去对焦
mEditText.setFocusable(false);
mEditText.setFocusableInTouchMode(true);
mEditText.setFocusable(true);
@jiemachina
jiemachina / android 自定义progressBar
Created September 17, 2012 03:15
android 自定义progressBar
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<shape>
<corners android:radius="0dip" />
<gradient
android:angle="270"
android:centerColor="#ff5a5d5a"
@jiemachina
jiemachina / 自定义progressBar 使用图片
Created September 17, 2012 03:29
自定义progressBar 使用图片
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background" android:drawable="@drawable/progress_bg" />
<item android:id="@android:id/secondaryProgress" android:drawable="@drawable/progress_fg_start" />
<item android:id="@android:id/progress" android:drawable="@drawable/progress_fg_start" />
</layer-list>
@jiemachina
jiemachina / gist:3736413
Created September 17, 2012 09:23
popuWindow 快速点击,背景透明
//背景不透明
mPopupWindow.setBackgroundDrawable(null);
final View contentView = getContentView();
//设置触摸事件 给 PopupWindow的ContentView重新设置触摸事件 解决setOutsideTouchable(true) 失效了,contentView为popuwindow的View
contentView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
final int x = (int) event.getX();
final int y = (int) event.getY();
@jiemachina
jiemachina / gist:3760716
Created September 21, 2012 10:01
webview 数据库基本设置
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDatabaseEnabled(true);
// mWebView.getSettings().setDomStorageEnabled(true);
// mWebView.requestFocus(View.FOCUS_DOWN);
mWebView.requestFocus(View.FOCUS_DOWN);
// mWebView.addJavascriptInterface(new
// JavaScriptInterface(RecommendActivity.this, bookId,bookName),
// "android");
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
@jiemachina
jiemachina / gist:3910321
Created October 18, 2012 07:44
根据文件路径,使用默认程序打开
Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW);
File file = new File(sdcardPath);
String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(file).toString());
String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
myIntent.setDataAndType(Uri.fromFile(file),mimetype);
mContext.startActivity(myIntent);