Đặt onItemLongClickListener cho custom ListViewandroid:descendantFocusability="blocksDescendants" Gửi result trở lại Intent resultIntent = new Intent;// TODO Add extras or a data setResu
Trang 1Đặ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);
Trang 2((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