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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:01:00+00:00 2026-06-08T01:01:00+00:00

I have the custom Listview. there are two textboxes and a checkbox. Xml files

  • 0

I have the custom Listview.
there are two textboxes and a checkbox.
Xml files are added, too.

package com.example.phonebook;

import java.util.ArrayList;
import java.util.List;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity implements AdapterView.OnItemClickListener{

ListView lst;

CustomPerson p;

private static final int CAMERA_REQUEST = 1888;
ImageView imageView;

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

    Button buttonSms, buttonCall, buttonPhoto;


    List<CustomPerson> list = new ArrayList<CustomPerson>();

    list = GetContacts();

    lst = (ListView) findViewById(R.id.lst_person);
    buttonSms= (Button) findViewById(R.id.btnSms);
    buttonCall = (Button) findViewById(R.id.btnCall);
    buttonPhoto = (Button) findViewById(R.id.BtnPhoto);


    lst.setAdapter(new CustomAdapter(getApplicationContext(),list));

    lst.setOnItemClickListener(this);

     public void onItemClick(AdapterView<?> parent, View view, int position,       long id) {

    // I want to get name and number here
     Toast.makeText(this,"Clicked!", Toast.LENGTH_LONG).show();
}

 @SuppressLint({ "NewApi", "NewApi" }) private List<CustomPerson> GetContacts()
{
    Intent intentContact = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); 
    List<CustomPerson> contactList = new ArrayList<CustomPerson>();

    Cursor cursor =  managedQuery(intentContact.getData(), null, null, null, null);      
       while (cursor.moveToNext()) 
       {          
           String Name = "";
           String PhoneNumber = "";
           String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
           Name = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); 

           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()) 
            {
              PhoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
            }
            phones.close();
           }

           contactList.add(new CustomPerson(Name, PhoneNumber));

      }          
       cursor.close();
       return contactList;
}

I have CustomPerson class and CustomAdapter.

When I click a person from listview, I want to get person’s phone and number to my object p.
But these setOnItemClickListener and OnItemClick methods don’t work, because when I run the project, I can’t click any items.

  • 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-08T01:01:02+00:00Added an answer on June 8, 2026 at 1:01 am

    This problem I think it’s for the clickable checkbox. Try to follow this similar issue with a button on a listview resolved early here:

    I can't click the ListView in android?

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

Sidebar

Related Questions

I have a problem now! I have custom ListView, there I have two TextView
I have created custom listview, each row looks like my file custom_row.xml. Is there
I have a custom ListView in which there are 2 buttons and a textview
I have a custom ListView with two button and I when I click either
Here's my aproach: I have a custom ListView containing a custom Adapter containing two
I have a custom ListView, the code is below. Instead of writing: http://yoursite.com/image1.png ,
I currently have a custom listview with two rows of text in each item,
I have a custom ListView with two TextViews , I have two string arrays
I have a custom listView. The main layout xml is something like this: <?xml
I know there are lots of questions related to Custom ListView with CheckBox but

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.