Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6757573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:40:10+00:00 2026-05-26T13:40:10+00:00

I need to add two text view to the list view as shown in

  • 0

enter image description here

I need to add two text view to the list view as shown in figure..what I need is that on the click of contact button the name and the type of number get automatically into my own list view..I am not been able to add text view to the list view because of that I am only able to see phone’s contact list…kindly help me please..thanks in advance..here is the code.

import android.app.ListActivity;

import android.os.Bundle;
import android.provider.ContactsContract;
import android.content.Intent;
import android.database.Cursor;

public class TestActivity extends ListActivity
{



    private static final int PICK_CONTACT = 0;

    /** Called when the activity is first created. */
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
      super.onCreate(savedInstanceState);       
    //content uri provide directory of people
      Intent intentContact = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); 

      startActivityForResult(intentContact, PICK_CONTACT);
    }//onCreate

    public void onActivityResult(int requestCode, int resultCode, Intent intent) 
    {

      if (requestCode ==PICK_CONTACT)
      { 
          getContactInfo(intent);               
      }



    }//onActivityResult

    protected void getContactInfo(Intent intent)
    {
String name;
       Cursor cursor =  managedQuery(intent.getData(), null, null, null, null);      
       while (cursor.moveToNext()) 
       {           
           //contains row id
           String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));

             name = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); 
         //whether contact list atleast have a single contact or not
           String hasPhone = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));

           if ( hasPhone.equalsIgnoreCase("1"))
               hasPhone = "true";
           else
               hasPhone = "false" ;

           if (Boolean.parseBoolean(hasPhone)) 
           {
            Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = "+ contactId,null, null);
            while (phones.moveToNext()) 
            {
              String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
            }//end
            phones.close();
           }//end

        cursor.close();
       }//end while 


    }//end method
}//end class...........

this is xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   >
<ListView
    android:id="@+id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />
<TextView
    android:id="@+id/android:empty"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />
</LinearLayout>........


<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:padding="6dip">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="fill_parent">
        <TextView
            android:id="@+id/toptext"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1"
            android:gravity="center_vertical"
        />
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1" 
            android:id="@+id/bottomtext"
            android:singleLine="true"
            android:ellipsize="marquee"
        />
    </LinearLayout>
</LinearLayout> ...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:40:10+00:00Added an answer on May 26, 2026 at 1:40 pm

    For this, you have to make custom list, Just Look at this tutorial
    Android Series: Custom ListView items and adapters
    or MonoDroid – Custom ListAdapter for your ListView

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two raw sound streams that I need to add together. For the
I need to add two lines of html to every page on a large
I have a SQL query (MS Access) and I need to add two columns,
I need to add background to a textview, the background has two parts: top
I've this simple form: <form id=commentForm method=POST action=api/comment> <input type=text name=name title=Your name/> <textarea
I have two text fields in which numbers are inputed as strings. I need
I need to add an input type image on a select. There's no drop
I need add a new user group for mediawiki. The new group has more
need to add a 2nd css stylesheet to a page. do i add a
I need to add a web part zone to a wiki page. I'm opening

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.