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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:19:15+00:00 2026-05-29T19:19:15+00:00

I have a ListView. I need to add items on listView on a condition(true).

  • 0

I have a ListView. I need to add items on listView on a condition(true). I have tried to clear adapter and then add true items.And also tried to remove the false items. But it seems I’m missing something.
Help me to find what am I missing.

here is main activity

protected void onCreate(Bundle savedInstanceState)
{

    super.onCreate(savedInstanceState);
    setContentView(R.layout.favorite_tab);

    list = (ListView) findViewById(R.id.listView1);
    mAdapter = new FavoriteListAdapter(this);

    list.setAdapter(mAdapter);
    getFavoriteChapt();
    list.setOnItemClickListener(this);

}

public void getFavoriteChapt()
{
    mAdapter.clear();
    for (int i = 0; i < 17; i++)
    {
        if (DataStore.getHierarchicalChapters().getSubChapters().get(i)
                .isFavorite() == true)
            mAdapter.add(DataStore.getHierarchicalChapters()
                    .getSubChapters().get(i));
    }
    mAdapter.notifyDataSetChanged();
}

And my CustomAdapter

    @Override
public View getView(int position, View convertView, ViewGroup parent)
{

    View row = convertView;

    if (row == null)
    {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        row = inflater.inflate(R.layout.favorite_tab_list_view_row, parent,
                false);
        ViewHolder viewHolder = new ViewHolder();
        viewHolder.text_view_sura_name = (TextView) row
                .findViewById(R.id.searchChapterTextViewId);

        row.setTag(viewHolder);
    }
    ViewHolder viewHolder = (ViewHolder) row.getTag();

    viewHolder.text_view_sura_name.setText(Integer.toString(position)
            + DataStore.getHierarchicalChapters().getSubChapters()
                    .get(position).getTitle());

    return row;
}
  • 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-29T19:19:17+00:00Added an answer on May 29, 2026 at 7:19 pm

    Here is my geFavoriteChapters

    private ArrayList<Chapter> getFavortiveChapters()
    {
        ArrayList<Chapter> chapter = new ArrayList<Chapter>();
    
        for (int i = 0; i < 17; i++)
        {
            if (DataStore.getHierarchicalChapters().getSubChapters().get(i)
                    .isFavorite())
                chapter.add(DataStore.getHierarchicalChapters()
                        .getSubChapters().get(i));          
        }
        return chapter;
    }
    

    and the View

    viewHolder.chapterName.setText(getFavoriveChapters().get(position).getTitle());
    

    and the Problem solved 🙂

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

Sidebar

Related Questions

I have a ListView which sometimes I need to put around 10000 items in.
I am trying to add ListView items one by one. So if I have
I have this code: foreach (var item in ListView1.Items) { ListView1.Items.Remove(item); ListView21.Items.Add(item); } the
I have a list view control that users can add items to but I
I have a listview but I would like to add 3 properties (for example
I have created an RSS reader that lists items in a listview. I also
I have a listview, and I need to fix the column width of the
I have a ListView containing file names. These file names need to be draggable
I have a ComboBox hosted in a ListView and I need changes in the
I have a Form with a listview. After calling Form.Show I need to update

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.