Skip to content

Instantly share code, notes, and snippets.

View Reacoder's full-sized avatar

赵小龙_同学 Reacoder

  • shanghai china
View GitHub Profile
@Reacoder
Reacoder / itemActivated
Created July 23, 2014 08:12
list item 选中状态。
item_layout's background.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/bg_music_list_item_selected" android:state_pressed="true"></item>
<item android:drawable="@drawable/bg_music_list_item_selected" android:state_selected="true"></item>
<item android:drawable="@drawable/bg_music_list_item_selected" android:state_activated="true"></item>
<item android:drawable="@drawable/bg_music_list_item_normal" ></item>
@Reacoder
Reacoder / actionBarTitlePadding.xml
Created July 23, 2014 09:55
From http://stackoverflow.com/questions/9737101/padding-between-actionbars-home-icon-and-title EDIT: make sure you set this drawable as LOGO, not as your app icon like some of the commenters did. Just make an XML drawable and put it in the resource folder "drawable" (without any density or other configuration). The last step is to set this new d…
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/my_logo"
android:right="10dp"/>
</layer-list>
class PhotoDecodeRunnable implements Runnable {...    /*     * Defines the code to run for this task.     */    @Override    public void run() {        // Moves the current Thread into the background        android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);        ...        /*         * Stores the current Thread in the PhotoTask instance,         * so that the instance         * can interrupt the Thread.         */        mPhotoTask.setImageDecodeThread(Thread.currentThread());        ...    }...}
@Reacoder
Reacoder / TableLayout.xml
Created July 24, 2014 04:10
TableLayout
<TableLayout
android:id="@+id/mytubeplayer_user_info_table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:stretchColumns="0,1" >
<TableRow>
<TextView
@Reacoder
Reacoder / ListViewHeight.java
Created July 24, 2014 06:24
Android ListView fixed height item
short answer:
when inflating for convertView, instead of just
result = inf.inflate(R.layout.thread_item, null);
do
result = inf.inflate(R.layout.thread_item, parent, false);
explanation:
@Reacoder
Reacoder / moveUserInfoLayoutInY.java
Created July 24, 2014 10:00
动态改变margin 布局。
private void moveUserInfoLayoutInY(int marginTop) {
MarginLayoutParams marginParams = new MarginLayoutParams(mUserInfoLayout.getLayoutParams());
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, marginTop, getResources().getDisplayMetrics());
marginParams.setMargins((int)mUserInfoLayout.getLeft(), (int)px, 0, 0);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(marginParams);
mUserInfoLayout.setLayoutParams(layoutParams);
}
@Reacoder
Reacoder / replaceUrlPara.java
Created July 25, 2014 05:24
替换url 中的某个参数。
protected static String getRealPlayUrl(String playUrlWithTempSig, String sig) {
// http://r13---sn-a5m7ln7r.googlevideo.com/videoplayback?
// sparams=gcr%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&source=youtube
// &signature=74A5A84D017C326B86FBB2515BD6C00BCD85133A.E1CB6514CD41B99045FF236A3F7CF0F50F4AEC14&itag=22&key=yt5&mws=yes&gcr=cn&ms=au
// &ipbits=0&ratebypass=yes&expire=1406281956&upn=raAqucAppMU&id=o-AP5UIALOxGG5ae6zN-JNagnKvRQa_WtGXk8czf3NgFuW&mv=u&sver=3&ip=199.245.60.115
// &fexp=902408%2C924222%2C927622%2C934024%2C934030%2C941431%2C945066%2C946023&mt=1406260337&initcwndbps=1093375
String realUrl = playUrlWithTempSig.replaceFirst("signature="+"[^&]*", "signature="+sig);
System.out.println("======= realUrl ======="+realUrl);
return realUrl;
}
@Reacoder
Reacoder / AndroidStudio
Created July 26, 2014 03:19
AndroidStudio key map.
*F1 显示声明。
Shift+F1 浏览器查看声明
*Command+B 进入源码。
Command+F12 显示类中的所有方法。
*Option+Enter 修复提示,还可以提取字符串到value中。
@Reacoder
Reacoder / fragmentMenu.java
Created July 29, 2014 07:59
fragment 中显示action button。
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:musictube="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/action_play"
android:icon="@drawable/btn_all_actionbar_play"
android:orderInCategory="100"
android:showAsAction="ifRoom|withText"
android:title="@string/action_play"
musictube:showAsAction="always|withText"/>
@Reacoder
Reacoder / TableLayout.xml
Created July 30, 2014 02:45
TableLayout 每列的宽度相等。
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp" >
<TableRow>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"