Click here to Skip to main content
15,890,995 members
Home / Discussions / Android
   

Android

 
AnswerRe: Regarding social media integrating Pin
Afzaal Ahmad Zeeshan8-Jun-15 4:33
professionalAfzaal Ahmad Zeeshan8-Jun-15 4:33 
GeneralRe: Regarding social media integrating Pin
Arpit Jain8-Jun-15 5:22
Arpit Jain8-Jun-15 5:22 
AnswerRe: Regarding social media integrating Pin
Afzaal Ahmad Zeeshan8-Jun-15 5:27
professionalAfzaal Ahmad Zeeshan8-Jun-15 5:27 
AnswerRe: Regarding social media integrating Pin
Dadecki17-Jun-15 22:26
Dadecki17-Jun-15 22:26 
QuestionAndroid database Pin
Member 117499218-Jun-15 2:02
Member 117499218-Jun-15 2:02 
SuggestionRe: Android database Pin
David Crow8-Jun-15 2:59
David Crow8-Jun-15 2:59 
AnswerRe: Android database Pin
Richard MacCutchan8-Jun-15 2:59
mveRichard MacCutchan8-Jun-15 2:59 
AnswerRe: Android database Pin
Member 117540029-Jun-15 10:35
Member 117540029-Jun-15 10:35 
firstly take permission from android manifest

<uses-permission android:name="”android.permission.READ_CONTACTS”/">

after that take 2 xml activity one which contain listview and other contain textview

then after try to use this code in java file...

public class PhoneBookActivity extends Activity {


ListView listViewPhoneBook;


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.phone_book);

//get the ListView Reference from xml file
listViewPhoneBook=(ListView)findViewById(R.id.listPhoneBook);

//arrayColumns is the array which will contain all contacts name in your cursor, where the cursor will get the data from contacts database.
//Here we are displaying name only from the contacts database
String[] arrayColumns = new String[]{ContactsContract.Contacts.DISPLAY_NAME};
//arrayViewID is the id of the view it will map to here textViewName only , you can add more Views as per Requirement
int[] arrayViewID = new int[]{R.id.textViewName};

//reference to the phone contacts database using Cursor and URI in android.
Cursor cursor;
cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);

/*Create an Adapter with arguments layoutID, Cursor, Array Of Columns, and Array of Views which is to be Populated
This adapter will be associated with the listview to populate items directly. So this adapter is associated with
the each_contact.xml file to view in a activity */

SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.each_contact, cursor, arrayColumns, arrayViewID);
listViewPhoneBook.setAdapter(adapter);

/*this is extra code for click event of any item in the list view.*/

// To handle the click on List View Item
listViewPhoneBook.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView arg0, View v,int position, long arg3)
{
// position parameter gives the index or position of ListView Item which is Clicked
TextView tv=(TextView)v.findViewById(R.id.textViewName);
String name=tv.getText().toString();
Toast.makeText(getApplicationContext(), "Contact Selected: "+name, Toast.LENGTH_LONG).show();
}
});

}
}

best of luck dear... Smile | :)
GeneralRe: Android database Pin
Member 117499219-Jun-15 15:39
Member 117499219-Jun-15 15:39 
AnswerRe: Android database Pin
Dominic Burford11-Jun-15 18:38
professionalDominic Burford11-Jun-15 18:38 
QuestionAnimated ProgressBar in Xamarin Android in C# Pin
Tirumaleswara Reddy.K5-Jun-15 0:56
Tirumaleswara Reddy.K5-Jun-15 0:56 
AnswerRe: Animated ProgressBar in Xamarin Android in C# Pin
Richard MacCutchan5-Jun-15 2:37
mveRichard MacCutchan5-Jun-15 2:37 
QuestionSaving xml date in sql lite Pin
Member 117396203-Jun-15 9:11
Member 117396203-Jun-15 9:11 
AnswerRe: Saving xml date in sql lite Pin
Sascha Lefèvre3-Jun-15 9:38
professionalSascha Lefèvre3-Jun-15 9:38 
GeneralRe: Saving xml date in sql lite Pin
Member 117396203-Jun-15 18:59
Member 117396203-Jun-15 18:59 
GeneralRe: Saving xml date in sql lite Pin
Sascha Lefèvre3-Jun-15 19:37
professionalSascha Lefèvre3-Jun-15 19:37 
AnswerRe: Saving xml date in sql lite Pin
Richard MacCutchan3-Jun-15 21:45
mveRichard MacCutchan3-Jun-15 21:45 
AnswerRe: Saving xml date in sql lite Pin
Dadecki17-Jun-15 22:50
Dadecki17-Jun-15 22:50 
QuestionHow to be notified when user copy some text in any application ? Pin
MohsenSaleh3-Jun-15 2:53
MohsenSaleh3-Jun-15 2:53 
AnswerRe: How to be notified when user copy some text in any application ? Pin
Richard MacCutchan3-Jun-15 5:22
mveRichard MacCutchan3-Jun-15 5:22 
Questionandroid Pin
chrisny26-May-15 23:58
chrisny26-May-15 23:58 
AnswerRe: android Pin
User 171649227-May-15 0:23
professionalUser 171649227-May-15 0:23 
AnswerRe: android Pin
Richard MacCutchan27-May-15 1:15
mveRichard MacCutchan27-May-15 1:15 
AnswerRe: android Pin
Member 1052365028-May-15 6:31
Member 1052365028-May-15 6:31 
AnswerRe: android Pin
Dadecki17-Jun-15 22:54
Dadecki17-Jun-15 22:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.