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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:57:26+00:00 2026-05-15T14:57:26+00:00

I’m making a custom adapter so that I can display a list of items

  • 0

I’m making a custom adapter so that I can display a list of items with icons which looks like the menu that comes up when you long click the home screen.

For some reason though the list items are not clickable. The can be navigated to with the D-pad but they cannot be clicked in any way. I thought maybe the problem was with the AlertDialog I was using so I replaced a working adapter I had elsewhere but I have the same issue there.

My adapter looks like this:

ArrayList<IconListItem> mItems;
LayoutInflater mInflater;

public IconListAdapter(Context context, ArrayList<IconListItem> items) {
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mItems = items;
}

public IconListAdapter(Context context) { 
    this(context, new ArrayList<IconListItem>()); 
}

public void add(IconListItem item) {
    mItems.add(item);
    notifyDataSetChanged();
    return item;
}

public void remove(IconListItem item) {
    mItems.remove(item);
    notifyDataSetChanged();
}

@Override
public int getCount() {
    return mItems.size();
}

@Override
public IconListItem getItem(int position) {
    return mItems.get(position);
}

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

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View view;
    if(convertView == null){
        view = mInflater.inflate(R.layout.two_line_icon_list_item, null);
    } else {
        view = convertView;
    }


    IconListItem item = mItems.get(position);
    TextView lineOne = (TextView) view.findViewById(R.id.firstLine);
    TextView lineTwo = (TextView) view.findViewById(R.id.secondLine);
    ImageView iconImage = (ImageView) view.findViewById(R.id.icon);

    lineOne.setVisibility(View.VISIBLE);
    lineTwo.setVisibility(View.VISIBLE);
    iconImage.setVisibility(View.VISIBLE);

    lineOne.setText(item.getText());

    if (item.getSubtext() == null)
        lineTwo.setVisibility(View.GONE);
    else 
        lineTwo.setText(item.getSubtext());



    if (item.getIcon() == null)
        iconImage.setVisibility(View.GONE);
    else 
        iconImage.setImageDrawable(item.getIcon());


    return view;
}

And the XML it’s inflating:

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="6dip"
>
    <ImageView
        android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_marginRight="6dip"
    />
    <LinearLayout
        android:orientation="vertical"  
        android:layout_width="wrap_content"
        android:layout_weight="1"
        android:layout_height="fill_parent"
    >
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center_vertical"
            android:id="@+id/firstLine"
            android:ellipsize="marquee"
            android:inputType="text"
        />
        <TextView  
            android:layout_width="wrap_content"
            android:layout_height="0dip"
            android:layout_weight="1"          
            android:ellipsize="marquee"
            android:id="@+id/secondLine"
            android:inputType="text"
        />           
    </LinearLayout>
</LinearLayout>

EDIT:

When I say they are not clickable, I mean that they items do not highlight in orange when I press them nor does onItemClick ever get called.

In my code I have this, a different adapter for another purpose and it works perfectly

this.foos= foos;
fa = new FooAdapter(this.foos);
fooList.setAdapter(fa);

// View the details for an item when it is selected
fooList.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
            long arg3) {
        Intent i = new Intent(MyActivity.this, MyOtherActivity.class);
        i.putExtra("foo", ((fooAdapter)arg0.getAdapter()).getItem(arg2));
        i.putExtra("list_position", arg2);
        MyActivity.this.startActivityForResult(i, 0);
    }
});

But when I swap out the first 3 lines for

IconListAdapter ila = new IconListAdapter(this);
ila.add(0, "Test 1", android.R.drawable.ic_menu_mylocation);
ila.add(0, "Test 2", android.R.drawable.ic_menu_edit);
ila.add(0, "Test 3", android.R.drawable.ic_menu_search);
groupList.setAdapter(ila);

it stops working.

  • 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-15T14:57:27+00:00Added an answer on May 15, 2026 at 2:57 pm

    I found the problem. I deleted lines from my layout file one by one until I found the cause.

    The lines that were causing the problem were the two lines android:inputType="text". They must have been causing the system to think that the two TextViews were inputs. I changed it to android:inputType="none" and now it works.

    It certainly would have been nice if the huge tooltip saying that singleLine was deprecated had suggested that.

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

Sidebar

Related Questions

I would like to run a str_replace or preg_replace which looks for certain words
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string

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.