Show contacts in Navigation Drawer of android Activity

184 views Asked by At

I want to show All contacts in navigation drawer of android activity.

for that I created drawer_row.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/common_signin_btn_icon_disabled_dark" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/imageView1"
    android:text="Contact name"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_below="@+id/textView1"
    android:text="Number"
    android:textAppearance="?android:attr/textAppearanceMedium" />

So how to load contacts and how to add drag and drop functionality to row in navigation drawer.

when user drag a particular contact and drop on activity it will show contact details.

So how to add contacts in navigation drawer and make them dragable?

1

There are 1 answers

0
Gaurav On BEST ANSWER

Here I got it.

Layout

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>



    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"/>
</android.support.v4.widget.DrawerLayout>

Activity

ListView mDrawerList = (ListView) findViewById(R.id.left_drawer);
mDrawerList.setAdapter(new ArrayAdapter<String>(this,
                R.layout.drawer_list_item, ContactHandler.getListOfContactNames()));

Note : ContactHandler is class intaract with Contacts cursor