Add reference to a contact in an Edittext

Asked

Viewed 155 times

0

I am working on a project where I need a form in which it is possible to place a Contact. How can I add a reference to a calendar contact? This is 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 when touching it again (when the contact has already been selected), opens the contact data (can be in a popup window or in a new Activity).

  • You want a contact from the right Android contact list?

  • Exactly. I want me to be able to reference it inside a screen item.

1 answer

2


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

Knob

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

Implementation Click Curto button inside the Activity

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

Implementation Click Longo button inside 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 the onLongClick() returns a Boolean, thus returning true in the onLongClick() he discards the onClick when the long click is fired, otherwise both events will happen.

  • ah? I don’t think this is what the author wants.

  • Actually, that does help. I really wanted to know which Apis I can use to link the contact to Edittext, but this code he posted may help elsewhere in the project.

  • @Jorgeb. I found his question a little confusing but it was what I understood and as I am not yet allowed to comment on his question, I hope it will help within my interpretation. Consider that the question is confused? :)

  • @gh0st_h4wk Just change the button to Edittext since they are all view. It’s just a little confusing in terms of UI this visual behavior for the type of action you want.

  • Actually this is just the idea that I have, I don’t know if I’m really going to implement it that way. The biggest problem is I don’t know how to implement such an idea.

  • @gh0st_h4wk Well, isn’t that a contact book? The ideal is that there was a screen with a contact list and when clicking on a list item or a contact, then yes, would open a new Activity for viewing the data of this contact and then you could have the options of Edit or Delete, when editing Edittext would be editing enabled. What do you think?

  • It wouldn’t be an agenda, I just need to associate a contact with Edittext. I don’t need options to edit or delete it, just to view your data.

  • @gh0st_h4wk What exactly you call associating?

  • For example: when the user selects a contact, edittext shows its name and when the user touches it again, it opens the contact page

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.