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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:10:02+00:00 2026-06-08T17:10:02+00:00

I have a custom list adapter. Here it is: public class FilesAdapter extends ArrayAdapter<PutioFileLayout>

  • 0

I have a custom list adapter. Here it is:

public class FilesAdapter extends ArrayAdapter<PutioFileLayout> {

    Context context;
    int layoutResourceId;
    List<PutioFileLayout> data = null;

    public FilesAdapter(Context context, int layoutResourceId, List<PutioFileLayout> data) {
        super(context, layoutResourceId, data);
        this.layoutResourceId = layoutResourceId;
        this.context = context;
        this.data = data;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        FileHolder holder = null;

        if (row == null) {
            LayoutInflater inflater = ((Activity) context).getLayoutInflater();
            row = inflater.inflate(layoutResourceId, parent, false);

            holder = new FileHolder();
            holder.textName = (TextView) row.findViewById(R.id.text_fileListName);
            holder.textDescription = (TextView) row.findViewById(R.id.text_fileListDesc);
            holder.imgIcon = (ImageView) row.findViewById(R.id.img_fileIcon);

            row.setTag(holder);
        } else {
            holder = (FileHolder) row.getTag();
        }

        PutioFileLayout file = data.get(position);
        holder.textName.setText(file.name);
        holder.textDescription.setText(file.description);
        holder.imgIcon.setImageResource(file.icon);

        return row;
    }

    static class FileHolder {
        TextView textName;
        TextView textDescription;
        ImageView imgIcon;
    }
}

Pretty short and sweet. I have Spinners in my layout for each row, and I want the user to be able to click them, and get a contextual menu for each item. How can I implement this in my adapter?

My row.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="64dp" >

    <ImageView
        android:id="@+id/img_fileIcon"
        android:layout_width="36dp"
        android:layout_height="36dp"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:scaleType="fitCenter"
        android:src="@drawable/ic_launcher" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_toRightOf="@id/img_fileIcon"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/text_fileListName"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="12dp"
            android:layout_marginTop="12dp"
            android:ellipsize="end"
            android:maxLines="1"
            android:text="File name"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <FrameLayout
            android:id="@+id/descriptionFrame"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="12dp"
            android:layout_marginRight="30dp" >

            <TextView
                android:id="@+id/text_fileListDesc"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="File description" />
        </FrameLayout>
    </LinearLayout>

    <Spinner
        android:id="@+id/item_fileSpinner"
        android:layout_width="44dp"
        android:layout_height="match_parent"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:background="@drawable/spinner_background_ab_putio" />

</RelativeLayout>
  • 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-08T17:10:10+00:00Added an answer on June 8, 2026 at 5:10 pm

    Inside your getView() method get a reference to the spinner like this:

    Spinner spn = row.findViewById(R.id.item_fileSpinner);
    

    once you have the reference you can set its items by creating a SpinnerAdapter with all of your values and set it with

    spn.setAdapater(mSpinAdapter);
    

    I can give you a more specific example of how you’d create and fill your adapter if you can tell me what data you are hoping to fill the spinner with.

    then all thats left is to set an OnItemSelectedListener, which you can do like this.

    spn.setOnItemSelectedListner(new OnItemSelectedListener(){
    
        public void onItemSelected(AdapterView<?> parent, View view, int spnPosition, long id){
            //Do something
        }
    });
    

    Note the use of spnPosition in the onItemSelected callback. If you use position then you will no longer have access to the getView() parameter position so use a different name so that you can access both/either if needbe.

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

Sidebar

Related Questions

I have a custom list adapter: class ResultsListAdapter extends ArrayAdapter<RecordItem> { in the overridden
I have a custom ArrayAdapter populating a ListView . Here it is: public class
Here is a short List activity that calls a custom adapter to show class
I have a listview connected to a custom array adapter. This list shows information
I have a custom list view that is getting data from server and changing
I have implemented a custom list view which looks like the twitter timeline. adapter
Currently, I have a custom list adapter that has some logic that hide/show a
I have a AutoCompleteTextView and a custom AutoCompleteTextView adapter. my list has 20 items
I have used a custom array adapter to populate my list view.The problem i
I have created a custom ArrayAdapter to display data within ListView items from an

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.