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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:17:34+00:00 2026-06-09T06:17:34+00:00

I show a listview from the following string: String[] values = new String[] {

  • 0

I show a listview from the following string:

String[] values = new String[] { test1, test2, test3 };

The variables:

private String test1 = "test";
private String test2 = "test";
private String test3 = "test3";

Now I don’t want to show the strings that contain “test” in my listview.
Like this:

if (String == "test") {
*don't show in ListView*;}

And I want it to test all Strings at once if they contain “test”

How is it possible?

EDIT: Here the adapter code:

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, values);
    listView.setAdapter(adapter);
  • 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-09T06:17:35+00:00Added an answer on June 9, 2026 at 6:17 am

    Yup…

    if (values[i].equals("test")) // i being the iterator of your for-loop
    

    OR

    if (values[i].contains("test"))
    

    contains is a slow(er) string function though.

    You might want to use an ArrayList though… that way you can just add all those objects to the array list, then iterate through it… and remove them as you go…

    // Do something to add all items to your array list
    ...
    // Iterate through the list, removing what doesn't need to be there
    for (int i = 0; i < arrayList.size(); i++){
        if (arrayList.get(i).contains("test"))
            arrayList.remove(i);
    }
    

    …Then set ‘arrayList’ (or whatever you’ve called it) as the string list for your adapter. If you use the same constructor it’ll look like this…

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, arrayList.toArray());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can load a list with the following code String[] projection = new String[]
Android:How to display images from the web in a ListView?I have the following code
friends, i am using following custom adapter to show textview and checboxes in listview.
I learned from android dev tutorial and now I can make ListView. and it
I hava a listview like the following. The text in the TextView comes from
I'm trying to create a ListView with custom ArrayAdapter. Following the example from here.
I have one SubjectTabActivity and i need to show listview on this activity. But
In my listview I show thumbnails of small images in a certain folder. I
How to show edittext and listview and positive and negative button in dialogbox? I
i have a TabLayout that has a ListView to show as intent. I would

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.