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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:39:44+00:00 2026-06-05T07:39:44+00:00

My question is as follows. I would like to be able to read a

  • 0

My question is as follows. I would like to be able to read a text file into an array adapter. I have one TextView and 3 RadioButtons. So far I have managed to pass a string array which can be used to update the TextView. I have an array list as shown below

ArrayList<info> list = new ArrayList<info>();

    for(int i=1; i <= 3; i++)
    {
        Reader reader = new ResultsReader("C:/Users/ALEXDEV/workspace/Questions/src/quiz"+i+".txt");
        reader.read();

        String str = ((ResultsReader)reader).getInput();
        String data[] = str.split("<.>");

        info = q new info();
        q.question = data[0];
        q.choice1 = data[2];
        q.choice2 = data[3];
        q.choice3 = data[4];
        list.add(q);
    }

    for(Question qs: list) { 

      System.out.println("Q: "+qs.question); 
        System.out.println("Q: "+qs.choice1); 
        System.out.println("Q: "+qs.choice2); 
        System.out.println("Q: "+qs.choice3);   
    }

–

Q: The question
Q: answer one
Q: answer two
Q: answer three

So what i want todo is pass the arraylist to the arrayadapter so I can use the getView method to return the various results

So far I have tried to pass list which is the arraylist to the MySimpleArrayAdapter adapter = new MySimpleArrayAdapter(this, list);

public class CustomAdapter extends ArrayAdapter {

private ArrayList<Question> list;
private Context context;

public CustomAdapter(Context context, int textViewResourceId, ArrayList<Question> list) {
    super(context, textViewResourceId,list);
    this.context = context;
    this.list = list;
    // TODO Auto-generated constructor stub

}

public View getView(int position, View convertView, ViewGroup parent)
{
     View view = convertView;
        if (view == null) {
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
           view = inflater.inflate(R.layout.basic, null);
        }

        Question element = list.get(position);


        if (element!= null) {
            // My layout has only one TextView
            TextView itemView = (TextView) view.findViewById(R.id.questionText);

            if (itemView != null) {
                // do whatever you want with your string and long
                itemView.setText(String.format("%s %d", element.question, element.answer));
            }

         }


        return view;

}
  • 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-05T07:39:46+00:00Added an answer on June 5, 2026 at 7:39 am

    You’ll need to create a custom adapter to feed the listview.

    You can create a custom ArrayAdapter (example here) or BaseAdapter (example here).

    In either case, you will be overriding the getView method of the adapter to process your data into the various widgets in your layout.

    EDIT

    If the question is actually “how do I call the adapter?” then:

    private CustomAdapter my_adapter;
    
    my_adapter = new CustomAdapter(this, R.layout.row, list);
    setListAdapter(my_adapter);
    

    And follow one of the links above to create your CustomAdapter.

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

Sidebar

Related Questions

So I have a new and exciting question that I would dearly like answered.
I have a database where I would like users to be able to create
This is a follow-up question to the following if you would like to see:
This is a follow-up to my previous question I would like to find a
My question is as follows: I have given a workbook to multiple people. They
I have a django app with models as follows: A Question model An Answer
I have a series of 'tasks' that I would like to run in separate
This question is somehow a continuation of this one . I've been able to
First of all I would like to apologize for the question itself. I simply
i am new to work on xml.i have used an xml file as follows:

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.