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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:33:38+00:00 2026-06-08T06:33:38+00:00

I have a listview that is being populated by information from a database using

  • 0

I have a listview that is being populated by information from a database using a custom adapter to handle the individual views. What I am trying to do is disable certain items in that listview (it is a basic progression system, i.e. user finishes module 1, and then module 2 is unlocked).

I have seen mentions here and there to override areAllItemsEnabled() and isEnabled() methods in my adapter class. The problem I’m having is, areAllItemsEnabled() seems ok, but the isEnabled() method basically enables/disables the entire listview, not the individual item. Any help is appreciated, thanks in advance.

Adapter Class:

public class ModuleAdapter extends ArrayAdapter<Module> {

Context context;
int layoutResourceId;
Module data[];

public ModuleAdapter(Context context, int layoutResourceId,
        Module 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;
    ModuleHolder holder = null;

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

        holder = new ModuleHolder();
        holder.modJapTitle = (TextView)row.findViewById(R.id.moduleJapTitle);
        holder.modEngTitle = (TextView)row.findViewById(R.id.moduleEngTitle);
        holder.modComp = (TextView)row.findViewById(R.id.moduleCompletion);
        holder.modRating = (RatingBar)row.findViewById(R.id.moduleScore);

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

    Module module = data[position];
    holder.modJapTitle.setText(module.moduleJapaneseTitle);
    holder.modEngTitle.setText(module.moduleEnglishTitle);
    holder.modComp.setText(module.moduleCompletionRate);
    holder.modRating.setRating(module.moduleRating);

    return row;
}

static class ModuleHolder
{
    TextView modEngTitle;
    TextView modJapTitle;
    TextView modComp;
    RatingBar modRating;
}


@Override
public boolean areAllItemsEnabled() {
    return false;
}

@Override
public boolean isEnabled(int position) {
    return false;
}

}

Implementation in activity:

ModuleAdapter moduleData = new ModuleAdapter(this, R.layout.module_box_item, module_data);
    moduleData.areAllItemsEnabled();
    moduleData.isEnabled(0);
    ListView listView1 = (ListView)findViewById(R.id.moduleListContainer);
    listView1.setClickable(true);
    listView1.setAdapter(moduleData);
    listView1.setCacheColorHint(Color.TRANSPARENT);
    listView1.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            int temp = position + 1;
            Intent i = new Intent(Story.this, SkitSelect.class);
            i.putExtra("moduleToGet", temp);
            startActivity(i);
        }
    });

The view description for the individual items:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/moduleBox"
android:id="@+id/moduleBoxSingle"
android:focusableInTouchMode="false"
android:clickable="false"
android:focusable="false" >

<TextView
    android:id="@+id/moduleJapTitle"
    style="@style/moduleTitleJap" />
<TextView
    android:id="@+id/moduleCompletion"
    android:layout_above="@+id/moduleSepartor"
    style="@style/moduleCompletion" />
<View
    android:id="@+id/moduleSepartor"
    android:layout_below="@+id/moduleJapTitle"
    style="@style/moduleSeperator" />
<TextView
    android:id="@+id/moduleEngTitle"
    android:layout_below="@+id/moduleSepartor"
    style="@style/moduleTitleEng" />
<RatingBar
    android:id="@+id/moduleScore"
    android:layout_below="@+id/moduleSepartor"
    style="@style/moduleRating"
    android:layout_alignParentRight="true" />

</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-08T06:33:39+00:00Added an answer on June 8, 2026 at 6:33 am

    Ok I figured this out. The method was as simple as this:

    public boolean isEnabled(int position) {
    
        if (position == 2) {
            return false
        }
    
        return true;  
    }
    

    This has to be set in the custom adapter. Not called from the implementation in the activity. This was the problem since I was trying to do something like mycustomadapter.isEnabled(2) which is incorrect.

    Hope this helps someone else.

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

Sidebar

Related Questions

I am using a listView that is being populated from a database. I know
I have a ListView that is being populated with a custom adapter. I have
I have a ListView that is being populated with a custom adapter. I'd like
I have created a custom listview that is populated using a row.xml file. Each
I have a listView that is being updated from multiple threads, with the threads
I have a ListView template that's being used in several places and I'd like
I have a listview that generates thumbnail using a backgroundworker. When the listview is
when my ListView is being filled by a custom Array Adapter, I check for
The title pretty much says it all. I have a listview being populated by
I have a custom control template for a ListView that puts an extra line

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.