0

I have written an application with 5 Table Rows. What I want to do is, when i click on a particular Table Row, i want the Phone Contacts to be opened, and the selected contact be displayed on that Table Row. For Example : If I press table row 5, Contacts is opened and the selected contact should be placed on the Table row 5. I hope I am clear enough. Can you Please help me with this?

android
  • 125
  • 1
  • 1
  • 9
  • At which of the point you name are you getting. stuck? – Jordi Jan 04 '12 at 11:48
  • Actually I am having problems in opening the phone contacts when clicked on the Table row and I want to know how to display the selected number on the particular row. – android Jan 04 '12 at 13:10

1 Answers1

0

Another question about this has been answered: How to call Android contacts list?

For placing the contact into the right row, save a reference to the row from the onClickListener so this listrow can be altered when a contact has been selected. You could add a new child (addView) or replace some text that is one of the columns..

// Assumes you have some reference to the tablerow in the onClickListener.. like:
public void onClick(View v) { 
    if (v instanceof TableRow) {
         TableRow tr = (TableRow) v;

         String contactName = yourFunctionToGetAContact();

         TextView newContactTextView = new TextView(this); // replace this by your reference to your context (e.g. activity)
         newContactTextView.setText(contactName);
         tr.addView(newContactTextView, 0); // 0 means insert at first column
    }
}
Community
  • 1
  • 1
Jordi
  • 1,357
  • 12
  • 20
  • Thank you for your help..the contacts part worked..but is it possible for u to send me some code regarding placing the contact in the row?? – android Jan 06 '12 at 10:39
  • Did this answer your question? If not, please explain what is unclear. If it did answer your question, could you please mark the answer as the answer? – Jordi Jan 06 '12 at 16:09