Example usage for android.widget AdapterView setTag

List of usage examples for android.widget AdapterView setTag

Introduction

In this page you can find the example usage for android.widget AdapterView setTag.

Prototype

public void setTag(int key, final Object tag) 

Source Link

Document

Sets a tag associated with this view and a key.

Usage

From source file:learn2crack.activities.WnContactsListFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    // Notifies the parent activity that the user selected a contact. In a two-pane layout, the
    // parent activity loads a ContactDetailFragment that displays the details for the selected
    // contact. In a single-pane layout, the parent activity starts a new activity that
    // displays contact details in its own Fragment.
    mOnContactSelectedListener.onContactSelected(null);

    registerForContextMenu(parent);/*from  w w  w .j  a va 2  s. c o  m*/
    //parent.setTag(R.id.TAG_HAS_WN,v.getTag(R.id.TAG_HAS_WN));
    parent.setTag(R.id.TAG_CONTACT_ID, v.getTag(R.id.TAG_CONTACT_ID));
    parent.setTag(R.id.TAG_CONTACT, v.getTag(R.id.TAG_CONTACT));
    parent.showContextMenu();
    unregisterForContextMenu(parent);
}

From source file:learn2crack.activities.ContactsListFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    // Gets the Cursor object currently bound to the ListView
    final Cursor cursor = mAdapter.getCursor();

    // Moves to the Cursor row corresponding to the ListView item that was clicked
    cursor.moveToPosition(position);/* w w  w .j a v  a 2s . com*/

    // Creates a contact lookup Uri from contact ID and lookup_key
    final Uri uri = Contacts.getLookupUri(cursor.getLong(ContactsQuery.ID),
            cursor.getString(ContactsQuery.LOOKUP_KEY));

    // Notifies the parent activity that the user selected a contact. In a two-pane layout, the
    // parent activity loads a ContactDetailFragment that displays the details for the selected
    // contact. In a single-pane layout, the parent activity starts a new activity that
    // displays contact details in its own Fragment.
    mOnContactSelectedListener.onContactSelected(uri);

    registerForContextMenu(parent);
    parent.setTag(R.id.TAG_HAS_WN, v.getTag(R.id.TAG_HAS_WN));
    parent.setTag(R.id.TAG_CONTACT_ID, v.getTag(R.id.TAG_CONTACT_ID));
    parent.showContextMenu();
    unregisterForContextMenu(parent);

    // If two-pane layout sets the selected item to checked so it remains highlighted. In a
    // single-pane layout a new activity is started so this is not needed.
    if (mIsTwoPaneLayout) {
        getListView().setItemChecked(position, true);
    }
    //getListView().setItemChecked(position, false);
}