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

  • Home
  • SEARCH
  • 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 6792261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:56:50+00:00 2026-05-26T17:56:50+00:00

Here is my adapter code which currently assigns the values in the DataObject to

  • 0

Here is my adapter code which currently assigns the values in the DataObject to their respective locations in my layout.xml file. Next, I am trying to add an onclicklistener here which will just print to logcat the only id field that was clicked, rather than the contents of the entire row.

private class DataAdapter extends ArrayAdapter<DataObject> {

    private ArrayList<DataObject> items;

    public DataAdapter(Context context, int textViewResourceId, ArrayList<DataObject> items) {
        super(context, textViewResourceId, items);
        this.items = items;
    }

    @Override
    public long getItemId(int arg0) {
        return 1;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;
        if (view == null) {
            LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = vi.inflate(R.layout.data_row, null);
        }
        DataObject dataObject = items.get(position);
        if (dataElement != null) {
            TextView field1 = (TextView) view.findViewById(R.id.field1);
            TextView  field2= (TextView) view.findViewById(R.id.field2);
            TextView  id = (TextView) view.findViewById(R.id.field_id);
            if (field1 != null) {
                field1.setText("field1 " + dataOject.getField1);
            }
            if (field2 != null) {
                field2.setText("field2 " + dataOject.getField2);
            }

            view.setClickable(true);
            view.setOnClickListener

            // Would like to simply print the id in this method to Log, so that when a row is clicked, only id is printed



        }


return view;
    }

Thanks for any thoughts or ideas

  • 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-26T17:56:51+00:00Added an answer on May 26, 2026 at 5:56 pm

    You can get the value from the underlying datastructure which populates the list.
    For example if it is populated from a List and you know the position. Just get the corresponding element from the List

    For example i used this code in my project

    listView.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
             ContactItem contactItem = contactItemList.get(position);
                     ..
                }
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code, which takes two version identifiers in the form 1, 5,
I have one custom ListView called AreasListView which I've included in the XML file.
Here is my code for a simple cursor adapter. public class CursorList extends ListActivity
Here's my current code. Basically it's populating my list with 'com.teslaprime.prirt.Task@44ef98aO' which I assume
Basically my problem is that i've adapted a piece of code found here http://social.msdn.microsoft.com/Forums/en-US/vemapcontroldev/thread/62e70670-f306-4bb7-8684-549979af91c1
currently i'm studying MySQL, sorry for my newbie question. Here my question I have
I'm using System.Xml to get attributes from my xml file . It seems that
BACKGROUND: I have a GridView based on a fairly complex Adapter class which extends
I am working on activity which request one php file on server & this
Here's a basic regex technique that I've never managed to remember. Let's say I'm

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.