Tải bản đầy đủ (.doc) (2 trang)

tóm tắt một số code Android

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (96.5 KB, 2 trang )

Đặt onItemLongClickListener cho custom ListView

android:descendantFocusability="blocksDescendants"
Gửi result trở lại

Intent resultIntent = new Intent();// TODO Add extras or a data
setResult(Activity.RESULT_OK, resultIntent);
finish();
Nhận Result từ activity con

@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
// Check which request we're responding to
if (requestCode == PICK_CONTACT_REQUEST) {
// Make sure the request was successful
if (resultCode == RESULT_OK) {
// The user picked a contact.
// The Intent's data Uri identifies which contact was
selected.
// Do something with the contact here (bigger example
below)
}
}
}

Adapter

class PhongBanAdapter extends ArrayAdapter<PhongBan> {
private Activity context;
private int layoutID;


private List<PhongBan> dsPhongBan;
public PhongBanAdapter(Activity context, int resource, List<PhongBan> objects) {
super(context, resource, objects);
this.context=context;
this.layoutID=resource;
this.dsPhongBan=objects;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView=context.getLayoutInflater().inflate(layoutID,null);
PhongBan pb=dsPhongBan.get(position);


((TextView)convertView.findViewById(R.id.lvi_title)).setText(pb.toString());
((TextView)convertView.findViewById(R.id.lvi_desc)).setText(pb.getDetail());
return convertView;
}
}
onCreateContextMenu

public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenu.ContextMenuInfo menuInfo){
super.onCreateContextMenu(menu, v, menuInfo);
getMenuInflater().inflate(R.menu.context1, menu);
}
onContextItemSelected

ggggggg




Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×