Java代码: `
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
viewRoot = inflater.inflate(R.layout.fragment_contacts, container,
false);
Button btnAdd = (Button) viewRoot.findViewById(R.id.btn_add_contacts);
btnAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_PICK,
ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent,1);
Toast.makeText(getContext(), "Add Contacts",
Toast.LENGTH_SHORT).show();
}
});
return viewRoot;
}
`
现在我想从列表中选择联系人,然后将它们添加到列表视图中。