1gravity / Android-ContactPicker

A beautifully designed component to pick one or several contacts (including groups) from the Android contacts list
Apache License 2.0
66 stars 33 forks source link

Unable to start contact picker activity #21

Closed CyTrix95 closed 7 years ago

CyTrix95 commented 7 years ago

I just found this yesterday and decided to use this in my app due to its good features. I did everything as mentioned in the steps but when i am starting the activity I am getting a Toast message saying

Attribute undefined; "cp_textColorPrimary". Did you apply the correct theme

i have checked the documentation of library and heres what i did 1) Added dependency to gradle 2) Added activity file to manifest 3) Enabled contacts permission 4) below is the code

`Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MainActivity.this, ContactPickerActivity.class) .putExtra(ContactPickerActivity.EXTRA_THEME, R.style.ContactPicker_Theme_Dark)

                    .putExtra(ContactPickerActivity.EXTRA_CONTACT_BADGE_TYPE,
                            ContactPictureType.ROUND.name())

                    .putExtra(ContactPickerActivity.EXTRA_CONTACT_DESCRIPTION,
                            ContactDescription.ADDRESS.name())
                    .putExtra(ContactPickerActivity.EXTRA_SHOW_CHECK_ALL, true)
                    .putExtra(ContactPickerActivity.EXTRA_SELECT_CONTACTS_LIMIT, 0)
                    .putExtra(ContactPickerActivity.EXTRA_ONLY_CONTACTS_WITH_PHONE, false)

                    .putExtra(ContactPickerActivity.EXTRA_CONTACT_DESCRIPTION_TYPE,
                            ContactsContract.CommonDataKinds.Email.TYPE_WORK)

                    .putExtra(ContactPickerActivity.EXTRA_CONTACT_SORT_ORDER,
                            ContactSortOrder.AUTOMATIC.name());

            startActivityForResult(intent, REQUEST_CONTACT);
        }
    });`

can anyone please help me out with this

1gravity commented 7 years ago

Please also follow the Theming instructions in the readme. You need to either use one of the integrated themes or define the custom attributes in your theme

CyTrix95 commented 7 years ago

I have used the integrated theme.... I have posted the code above kindly take a look please and tell me what i am doing wrong....thank you

1gravity commented 7 years ago

You clearly haven't applied the theme correctly or you wouldn't get the error message Attribute undefined; "cp_textColorPrimary". Did you apply the correct theme

Everything you need is described here: https://developer.android.com/guide/topics/ui/themes.html

1gravity commented 7 years ago

There was a typo in one the the style definitions, try the new version 1.3.2