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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:04:26+00:00 2026-05-26T05:04:26+00:00

I’m trying to fill a ListView with a String[]. The problem is that i

  • 0

I’m trying to fill a ListView with a String[]. The problem is that i want to make this filling when i find occurences with another array.
I try to explain. I have an ArrayList [0,1,0,0,1,…]
This changes everytime an user give some answers to a quiz session. Example: 10 questions, 10 answers and so ArrayList’s size = 10.
As you can see 0 is for “wrong answer” and 1 is for “correct answer”. So i create an ArrayList with the maximum size depending on database’s quiz table and this is called “domandesatte”.

So i made this 2 String[]: one for correct answer (“Domanda #: Esatta means Question # : CORRECT) and one for wrong answer (“Domanda #: ERRATA!” means “Question #: Wrong”)

Finally “vettoreint” is the ArrayList which i get from Intent.getIntegerArrayListExtra();

listView = (ListView)findViewById(R.id.list2);
      listView.setTextFilterEnabled(true);
        listView2 = (ListView)findViewById(R.id.listSbagliato);
          listView2.setTextFilterEnabled(true);
final String[] domandesatte = {"Domanda n°1: ESATTA!","Domanda n°2: ESATTA!","Domanda n°3: ESATTA!",
            "Domanda n°4: ESATTA!","Domanda n°5: ESATTA!","Domanda n°6: ESATTA!",
            "Domanda n°7: ESATTA!","Domanda n°8: ESATTA!","Domanda n°9: ESATTA!",
            "Domanda n°10: ESATTA!","Domanda n°11: ESATTA!","Domanda n°12: ESATTA!",
            "Domanda n°13: ESATTA!","Domanda n°14: ESATTA!","Domanda n°15: ESATTA!",
            "Domanda n°16: ESATTA!","Domanda n°17: ESATTA!","Domanda n°18: ESATTA!",
            "Domanda n°19: ESATTA!","Domanda n°20: ESATTA!","Domanda n°21: ESATTA!",
            "Domanda n°22: ESATTA!","Domanda n°23: ESATTA!"};

final String[] domanderrate = {"Domanda n°1: ERRATA!","Domanda n°2: ERRATA!","Domanda n°3: ERRATA!",
            "Domanda n°4: ERRATA!","Domanda n°5: ERRATA!","Domanda n°6: ERRATA!",
            "Domanda n°7: ERRATA!","Domanda n°8: ERRATA!","Domanda n°9: ERRATA!",
            "Domanda n°10: ERRATA!","Domanda n°11: ERRATA!","Domanda n°12: ERRATA!",
            "Domanda n°13: ERRATA!","Domanda n°14: ERRATA!","Domanda n°15: ERRATA!",
            "Domanda n°16: ERRATA!","Domanda n°17: ERRATA!","Domanda n°18: ERRATA!",
            "Domanda n°19: ERRATA!","Domanda n°20: ERRATA!","Domanda n°21: ERRATA!",
            "Domanda n°22: ERRATA!","Domanda n°23: ERRATA!"};

for(int i=0;i<vettoreint.size();i++)
        {
     if (vettoreint.get(i) == 1) {

         listView.setAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, domandesatte));
        listView.setTextFilterEnabled(true);    
     }
     else {
         if(vettoreint.get(i) == 0)
         {

         listView2.setAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, domandesatte));
        listView2.setTextFilterEnabled(true);   

         }
        }
        }

All i want to do is to see 2 ListViews (1 for correct answer and 1 for wrong answer) depending on the ArrayList Example: 10 Answers, 5 “Question # Correct”, 5 “Question # Wrong”.

I try to put domandesatte[i] but it is not correct according to Adapter.
So i tried to put subList(i,i+1) but it returns only the last two occurrences: one for correct and one for wrong.

Do you have any suggests? sorry for my english and thank you for all your great support!

  • 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-26T05:04:26+00:00Added an answer on May 26, 2026 at 5:04 am

    I don’t know if i’m understanding your problem but couldn’t you do it like this:

    private ArrayList<String> domandesatte = new ArrayList<String>();
    private ArrayList<String> domanderrate = new ArrayList<String>();
    
    ....
    
    for(int i=0;i < vettoreint.size();i++) {
         if (vettoreint.get(i) == 1) {
             domandesatte.add("Domanda n°" + i + ": ESATTA!");
         } else {
             domanderrate.add("Domanda n°" + i + ": ERRATA!");
         }
    }
    
    listView.setAdapter(new ArrayAdapter<String>(this,
                    android.R.layout.simple_list_item_1, domandesatte));
    
    listView2.setAdapter(new ArrayAdapter<String>(this,
                    android.R.layout.simple_list_item_1, domanderatte));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is

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.