内置方法

  • type() 查看数据类型
  • dir() 返回所以属性和方法
  • help() 返回帮助信息
  • range(x,y) 获取x到y-1的元素

列表

常用方法

  • count() 列表含多少元素
  • index(x) 差选下标为x的元素
  • append() 在末尾添加元素
  • sort() 排序
  • pop() 或许最后一个元素,并去除
  • remove() 删除元素
  • insert(x,y) 在下边x的位置插入y

字典

常用方法

  • keys() 返回dict所有键
  • values() 返回dict所有值
  • items() 返回dict所有元素
  • clear() 清空dict
  • del dic{‘tom’} 删除’tom’元素
  • len() 获取地点的元素总数
1
2
3
4
5
6
7
8
9
10
dic = {'zoe':1,'joy':2,'tom':3}
print dic
print len(dic)
print dic.keys()
print dic.values()
print dic.items()
del dic['tom']
print dic
dic.clear()
print dic

生成ssh-key

Clone and Push

创建和切换分支

  • 创建分支 git branch new_branch_name
  • 切换分支 git checkout target_branch_name
  • 删除分支 -D target_branch_name

推送到远程分支

  • git push origin local_branch_name:remote_branch_name

合并分支

  • git merge source_branch

标记

  • git tag xxx


主界面

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/product_list"
android:cacheColorHint="# 00000000"
/>
<RelativeLayout
android:id="@+id/shopping_cart"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="20dp"
android:paddingBottom="22dp"
android:gravity="center_vertical">
<ImageView
android:id="@+id/shopping_img_cart"
android:layout_width="50dp"
android:layout_height="50dp"
android:padding="1dp"
android:layout_alignParentLeft="true"
android:scaleType="centerInside"
android:src="@drawable/shopping_cart"/>
</RelativeLayour>
</RelativeLayout>

item项

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<RlativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="48dp">
<Button
android:id="@+id/product_buy_btn"
android:layout_width="40dp"
android:layout_height="48dp"
android:layout_alignParentRight="true"
android:layout_gravity="center_vertical"
android:layout_margin="10dp"
android:text="购买"
android:textColor="# F8720D"
android:textSize="12sp" />
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="48dp"
android:paddingLeft="10dp"
android:text="商品"
android:textSize="18sp"
android:gravity="center_vertical"
android:layout_toLeftOf="@id/product_buy_btn"
/>
</RlativeLayout>

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
public class MainActivity extends Activity {

private ListView mListView;
private ImageView shopCart;
private ImageView buyImg;
private ViewGroup anim_mask_layout;//动画层

private Context mContext;
private ProductAdapter productAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mContext = this;
initView();
}

private void initView() {
shopCart = (ImageView) findViewById(R.id.shopping_img_cart);
mListView = (ListView) findViewById(R.id.product_list);
productAdapter = new ProductAdapter();
mListView.setAdapter(productAdapter);
}

private class ProductAdapter extends BaseAdapter {

public ProductAdapter() {
}

@Override
public int getCount() {
return 20;
}

@Override
public String getItem(int position) {
return "商品" + (position + 1);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView,
final ViewGroup parent) {
String name = getItem(position);
ViewHolder holder = null;
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(
R.layout.item, null);
holder = new ViewHolder();
holder.nameTxt = (TextView) convertView.findViewById(R.id.name);
holder.buyBtn = (Button) convertView
.findViewById(R.id.product_buy_btn);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.nameTxt.setText(name);
holder.buyBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int[] start_location = new int[2];
v.getLocationInWindow(start_location);
buyImg = new ImageView(mContext);
buyImg.setImageResource(R.drawable.sign);
setAnim(buyImg, start_location);
}
});
return convertView;
}

class ViewHolder {
TextView nameTxt;
Button buyBtn;
}

}

private ViewGroup createAnimLayout() {
ViewGroup rootView = (ViewGroup) this.getWindow().getDecorView();
LinearLayout animLayout = new LinearLayout(this);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
animLayout.setLayoutParams(lp);
animLayout.setId(Integer.MAX_VALUE);
animLayout.setBackgroundResource(android.R.color.transparent);
rootView.addView(animLayout);
return animLayout;
}

private View addViewToAnimLayout(final ViewGroup vg, final View view,
int[] location) {
int x = location[0];
int y = location[1];
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
lp.leftMargin = x;
lp.topMargin = y;
view.setLayoutParams(lp);
return view;
}

private void setAnim(final View v, int[] start_location) {
anim_mask_layout = null;
anim_mask_layout = createAnimLayout();
anim_mask_layout.addView(v);//把动画小球添加到动画层
final View view = addViewToAnimLayout(anim_mask_layout, v,
start_location);
int[] end_location = new int[2];// 这是用来存储动画结束位置的X、Y坐标
shopCart.getLocationInWindow(end_location);// shopCart是那个购物车



// 计算位移
int endX = 0 - start_location[0] + 40;
int endY = end_location[1] - start_location[1];
Log.d("---", endX+""+endY);
TranslateAnimation translateAnimationX = new TranslateAnimation(0,
endX, 0, 0);
translateAnimationX.setInterpolator(new LinearInterpolator());
translateAnimationX.setRepeatCount(0);// 动画重复执行的次数
translateAnimationX.setFillAfter(true);

TranslateAnimation translateAnimationY = new TranslateAnimation(0, 0,
0, endY);
translateAnimationY.setInterpolator(new AccelerateInterpolator());
translateAnimationY.setRepeatCount(0);// 动画重复执行的次数
translateAnimationX.setFillAfter(true);

AnimationSet set = new AnimationSet(false);
set.setFillAfter(false);
set.addAnimation(translateAnimationY);
set.addAnimation(translateAnimationX);
set.setDuration(Math.abs(endY/1));// 动画的执行时间
v.startAnimation(set);
set.setAnimationListener(new AnimationListener() {
// 动画的开始
@Override
public void onAnimationStart(Animation animation) {
v.setVisibility(View.VISIBLE);
}

@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}

// 动画的结束
@Override
public void onAnimationEnd(Animation animation) {
v.setVisibility(View.GONE);
}
});
}
}

例子

https://github.com/SeniorZhai/ShoppingAnimation