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 9071421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:54:32+00:00 2026-06-16T17:54:32+00:00

Using the following class I want to select the contact from list which has

  • 0

Using the following class I want to select the contact from list which has Contact Name and Number.

public class MakeCallView extends Activity implements OnItemClickListener {

    Button callButtn;
    EditText number2call;
    private ListView lv1 = null;
    Cursor cursor = null;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.makeacall);

        cursor = getContentResolver().query(
                ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null,
                null, null);
        callButtn = (Button) findViewById(R.id.CallBtn);
        number2call = (EditText) findViewById(R.id.number2Call);
        lv1 = (ListView) findViewById(R.id.listContact);

        ListAdapter adapter1 = new SimpleCursorAdapter(this,


            android.R.layout.simple_list_item_2, cursor, new String[] {
                        ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
                        ContactsContract.CommonDataKinds.Phone.NUMBER },
                new int[] { android.R.id.text1, android.R.id.text2 });

        lv1.setAdapter(adapter1);
        lv1.setOnItemClickListener(this);

        callButtn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {


                // TODO Auto-generated method stub

            }

        });
    }



    @Override
    public void onItemClick(AdapterView<?> adapter, View arg1, int pos,
            long arg3) {

        try {

            Cursor c = (Cursor) adapter.getItemAtPosition(pos);

            View v = adapter.getFocusedChild();
            // TwoLineListItem row = (TwoLineListItem)
            // adapter.getAdapter().getView(pos, arg1,
            // (ViewGroup)adapter.getParent());
            // String a = (String)adapter.getItemAtPosition(pos);
            // number2call.setText( c.g);
            Log.v("GPS", "arg3    : " + c.getColumnCount());
            Log.v("GPS", "arg3    : " + c.getColumnNames());
            Log.v("GPS", "arg3    : " + c.toString());
            Log.v("GPS", "arg3    : " + c.getShort(1));

            Log.v("GPS", "arg3    : " + c.getColumnIndex("text2"));
        } catch (Exception e) {
            // TODO Auto-generated catch block
            Log.v("GPS", e.getMessage(), e);
        }

        // number2call.setText(((TextView)arg1).getText().toString());

        // Handle list2 click even

    }

}

From the above code, in the onItemClick(), the selected contact number should be retrieved which I am not able to get. Please help out.

  • 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-06-16T17:54:33+00:00Added an answer on June 16, 2026 at 5:54 pm

    try this in your OnItemClickListener

    TextView txtNumber = (TextView) arg1.findViewById(android.R.id.text2)
    String str = txtNumber.getText()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to mock only the GetValue method of the following class, using Moq:
I am using the following code class AddTask extends AsyncTask<Void, Void, Void> { ProgressDialog
I am trying to register the following class using the fluent interface: public class
I'm using the following mapping: public class LoadMap : IAutoMappingOverride<Load> { public void Override(AutoMapping<Load>
for the following html <div> <div class=col1 > I dont want to select this
I've got the following classes: public class SupplierCategory : IEquatable<SupplierCategory> { public string Name
Let's say I have the following class. MyClass<T> { public void MyMethod(T a, List<T>
I'm using Castle Windsor, and I've got the following: public class NhibernateRepository<T> : IRepository<T>
I want to select number 4 or 5 links i have tried using this
I want to select first elements of a class which are children of elements

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.