Add reference to a contact in EditText

0

I'm working on a project where I need a form in which it's possible to put a Contact. How do I add a reference to a calendar contact? Is this possible?

My idea was something like: user touches the EditText of the contact, a window appears in which he can select a contact. In EditText is the name of the contact, but touching it again (when the contact has already been selected) opens the contact data (it can be in a popup window or a new Activity ).

    
asked by anonymous 07.05.2014 / 16:42

1 answer

2

Use the short click implementation to select the contact and the long click to open the contact data.

Button

Button botao = (Button) findViewById(R.id.botao);

Short Click implementation within the

botao.setOnClickListener(new OnClickListener() { 
    @Override
    public void onClick(View v) {
        // Sua Implementação aqui
    }
});

Long Click implementation of the button within the Activity

botao.setOnLongClickListener(new OnLongClickListener() { 
    @Override
    public boolean onLongClick(View v) {
        // Sua implementação aqui como por exemplo chamar uma nova Activity:
        // Intent intent = new Intent(this, NovaActivity.class);
        return true;
    }
});

Note that onClick () returns void and onLongClick () returns a boolean, thus returning true on onLongClick () it discards the onClick when the long click is triggered, otherwise both events will happen.

    
07.05.2014 / 17:03