xml文件:
android:id="@+id/flowlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp"
f:horizontalSpacing="60dip"
f:verticalSpacing="12dip" />
mNearestLayout = (FlowLayout)findViewById(R.id.flowlayout);
mNearestLayout.setHorizontalFadingEdgeEnabled(true);
List> recent = getRecentContact();
for (int i = 0; i < recent.size(); i++) {
final String name = recent.get(i).get("name");
final String phoneNumber = recent.get(i).get("phoneNumber");
TextView tv = new TextView(this);
tv.setGravity(Gravity.CENTER);
tv.setTextSize(16);
tv.setText(name);
tv.setBackgroundResource(R.drawable.skin_apply);
tv.setTextColor(Color.BLACK);
tv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ArrayList numbers = mReceiverEditor.getNumberList();
if(numbers.contains(phoneNumber)){
HaloToast.show(getApplicationContext(), "该联系人已经被选中");
return;
}
mReceiverEditor.resetReceiver(new ReceiverData(name,phoneNumber));
mReceiverEditor.getEditor().requestFocus();
}
});
mNearestLayout.addView(tv);
}
//end
阅读(1250) | 评论(0) | 转发(0) |