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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:23:51+00:00 2026-05-29T08:23:51+00:00

I created a file in \res\layout named contactlist.xml But it is not recognized in

  • 0

I created a file in \res\layout named contactlist.xml

But it is not recognized in my code:

SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this,
        //android.R.layout.simple_list_item_1, mContacts, //if cre8 own layout, replace "simple_[etc]"
        //android.R.layout.simple_list_item_checked, mContacts, // or simple_list_item_multiple_choice
        //android.R.layout.simple_list_item_multiple_choice, mContacts,
        android.R.layout.contactlist, mContacts, // <- contact list ist xml-non-grata
        new String[] { ContactsContract.Contacts.DISPLAY_NAME },
        new int[] { android.R.id.text1 });

I want to create a custom layout that for each Contact has three checkboxes.

Why is my custom layout not accepted as valid?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Updated 2/9/2012:

Finally!

With the help of stackOverflowers and this article: http://www.vogella.de/articles/AndroidListView/article.html

I finally got it working; as usual, it’s not that tough once you grok a couple of concepts. It boils down to using this sort of code, which I begged/borrowed/stole and adapted:

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

// Return all contacts, ordered by name
String[] projection = new String[] { ContactsContract.Contacts._ID,
        ContactsContract.Contacts.DISPLAY_NAME }; 
mContacts = managedQuery(ContactsContract.Contacts.CONTENT_URI,
        projection, null, null, ContactsContract.Contacts.DISPLAY_NAME);

// Display all contacts in a ListView
SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this,
        R.layout.ondemandandautomatic_authorize, mContacts,
        new String[] { ContactsContract.Contacts.DISPLAY_NAME },
        new int[] { R.id.contactLabel });

setListAdapter(mAdapter);

}

…and making sure “ondemandandautomatic_authorize” (or whatever you name your layout file) is something like this (unfinished, but you get the idea):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <CheckBox
        android:id="@+id/checkBox1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="1" />

        <CheckBox
        android:id="@+id/checkBox2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="2" />

        <CheckBox
        android:id="@+id/checkBox3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="3" />

    <TextView
        android:id="@+id/contactLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="(replace this)"
        android:textSize="20px" >
    </TextView>

</LinearLayout>

…and that “R.id.contactLabel” is replaced with “R.id.”

There’s more to be done, obviously, but a big obstacle has been hurdled.

  • 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-29T08:23:52+00:00Added an answer on May 29, 2026 at 8:23 am

    It should be

    R.layout.contactlist
    

    and not

    android.R.layout.contactlist
    

    android is used when you are using the system resources.

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

Sidebar

Related Questions

In my android application i created and xml file in \res\layout\admin.xml the layouts i
I have created XML file,but I can't view it/output it.I know there is no
I have created a file named MyFile.db using SQLite3 from my C#.net application. This
I have a main activity with this layout file: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I created a state-list selector file item_bg_selector.xml in the drawable folder like this :
I created a file download script in PHP, it works, but web browsers report
I have created a file with XmlDocument xmldoc = new XmlDocument(); Can I make
I have compiled and created .WAR file of my java code. then i started
When I created a preferences xml file (by right-clicking the project name, selecting |
I have created a Table Layout named table and I am trying to add

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.