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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:01:47+00:00 2026-06-12T00:01:47+00:00

I’ve an app where i am displaying a record I’ve got from a webservice.

  • 0

I’ve an app where i am displaying a record I’ve got from a webservice. The record has 5 fields, startTime, duration, status, and clientname. (clientname is actually made up of 2 fields first and last). I can get the fields from an arrayList into a String array and then pass that array to the adapter. The fields are displayed in the ListView. All good so far, apart from the same record is shown 5 time in the ListView. Why is this? I pass the array in once to the adapter.

public class GetRota extends Activity {

    private static final String TAG = GetRota.class.getSimpleName();
    ListView listView;
    Intent intent;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.getrotalayout);

        listView = (ListView)findViewById(R.id.rotalist);
        intent = this.getIntent();
        Bundle bundle = intent.getBundleExtra("rotaArrayBundle");

        @SuppressWarnings("unchecked")
        ArrayList array =  (ArrayList) bundle.get("rotaArray");





        for(int i = 0; i < array.size(); i++){

             Log.e(TAG, "array pos " + i + " = " +  array.get(i));

        }

        String record = array.get(0).toString();
        String[] itemsInRecord = record.split(",");
        String[] recordItem = new String[5];

       for(int x = 0; x < itemsInRecord.length; x++){

           Log.e(TAG, "token = " + itemsInRecord[x]);
           recordItem[x] = itemsInRecord[x];
      }

       MySimpleArrayAdapter arrayAdapter = new MySimpleArrayAdapter(this, recordItem);
       listView.setAdapter(arrayAdapter);


    }// end of onCreate


    private class MySimpleArrayAdapter extends ArrayAdapter<String> {
          private final Context context;
          private final String[] values;

          public MySimpleArrayAdapter(Context context, String[] values) {
            super(context, R.layout.rotarowlayout, values);
            this.context = context;
            this.values = values;
          }

          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View rowView = inflater.inflate(R.layout.rotarowlayout, parent, false);
           TextView startTime = (TextView)rowView.findViewById(R.id.rowstarttime);
           TextView duration = (TextView)rowView.findViewById(R.id.rowduration);
           TextView status = (TextView)rowView.findViewById(R.id.rowstatus);
           TextView name = (TextView)rowView.findViewById(R.id.rowclientname);

           startTime.setText("Start Time: " + values[0]);
           duration.setText("Duration:" + values[1]);
           status.setText("Status:" + values[2]);
           name.setText("Client:" + values[3] + values[4]);



            return rowView;
          }
        } 

}// end of GetRota

.
[update]

private class MySimpleArrayAdapter extends BaseAdapter {
          private final Context context;
          private final ArrayList array;

          public MySimpleArrayAdapter(Context context, ArrayList array) {
            this.context = context;
            this.array = array;
          }

        public int getCount() {
            return array.size();
        }

        public Object getItem(int position) {
            return array.get(position);
        }

        public long getItemId(int position) {
            return position;
        }

          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
            String[] values = array.get(position).toString();
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View rowView;

            if (convertView == null) { // if it's not recycled, initialize some
                                    // attributes
                rowView = new View(context);
                // get layout from gridview_item.xml
                rowView = inflater.inflate(R.layout.rotarowlayout, parent, false);
            } else {
                rowView = (View) convertView;
            }


           TextView startTime = (TextView)rowView.findViewById(R.id.rowstarttime);
           TextView duration = (TextView)rowView.findViewById(R.id.rowduration);
           TextView status = (TextView)rowView.findViewById(R.id.rowstatus);
           TextView name = (TextView)rowView.findViewById(R.id.rowclientname);

           startTime.setText("Start Time: " + values[position][0]);
           duration.setText("Duration:" + values[position][1]);
           status.setText("Status:" + values[position][2]);
           name.setText("Client:" + values[position][3] + values[position][4]);




            return rowView;
          }
        } 

[update hitesh]

private class MySimpleArrayAdapter extends ArrayAdapter<String> {
        private final Context context;
        private final ArrayList<String[]> list;

        public MySimpleArrayAdapter(Context context,ArrayList<String[]> list) 
        {      

        super(context, R.layout.rotarowlayout);
         Log.e(TAG, "inside adapter constructor");
                this.context = context;           
                this.list= list;
              }

              @Override
              public View getView(int position, View convertView, ViewGroup parent) {
                  Log.e(TAG, "inside getView");
                LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

               View rowView = inflater.inflate(R.layout.rotarowlayout, parent, false);

               TextView startTime = (TextView)rowView.findViewById(R.id.rowstarttime);
               TextView duration = (TextView)rowView.findViewById(R.id.rowduration);
               TextView status = (TextView)rowView.findViewById(R.id.rowstatus);
               TextView name = (TextView)rowView.findViewById(R.id.rowclientname);

               String[] values = list.get(position);

               startTime.setText("Start Time: " + values[0]);
               Log.e(TAG, "starttime = " + startTime);
               duration.setText("Duration:" + values[1]);
               status.setText("Status:" + values[2]);
               name.setText("Client:" + values[3] + values[4]);



                return rowView;

              }


              @Override
              public int getCount() {
                  return this.list.size();
              }

    }// end of adapter class
  • 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-12T00:01:49+00:00Added an answer on June 12, 2026 at 12:01 am

    actualy ur code is smwt wrong. use
    ArrayList list of string arrays

    for(int i=0;i<array.length;i++)
    {
    String record = array.get(i).toString();
    String[] itemsInRecord = record.split(",");
    list.add(record);      }
    

    Customize ur adapter also. MySimpleArrayAdapter arrayAdapter = new MySimpleArrayAdapter(this, list);
    listView.setAdapter(arrayAdapter);

    private class MySimpleArrayAdapter extends ArrayAdapter<String> {
    private final Context context;
    private final Arraylist< String[]> list;
    public MySimpleArrayAdapter(Context context,Arraylist< String[]> list) 
    {         
    super(context, R.layout.rotarowlayout,list);
            this.context = context;           this.list= list;
          }
    
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View rowView = inflater.inflate(R.layout.rotarowlayout, parent, false);
           TextView startTime = (TextView)rowView.findViewById(R.id.rowstarttime);
           TextView duration = (TextView)rowView.findViewById(R.id.rowduration);
           TextView status = (TextView)rowView.findViewById(R.id.rowstatus);
           TextView name = (TextView)rowView.findViewById(R.id.rowclientname);
    String[] values= list.get(position);
           startTime.setText("Start Time: " + values[0]);
           duration.setText("Duration:" + values[1]);
           status.setText("Status:" + values[2]);
           name.setText("Client:" + values[3] + values[4]);
    
    
    
            return rowView;}}
    

    In ur activity class, replace

    ArrayList array =  (ArrayList) bundle.get("rotaArray");
        for(int i = 0; i < array.size(); i++){
    
             Log.e(TAG, "array pos " + i + " = " +  array.get(i));
    
        }
        String record = array.get(0).toString();
        String[] itemsInRecord = record.split(",");
        String[] recordItem = new String[5];
    
       for(int x = 0; x < itemsInRecord.length; x++){
    
           Log.e(TAG, "token = " + itemsInRecord[x]);
           recordItem[x] = itemsInRecord[x];
      }
    
       MySimpleArrayAdapter arrayAdapter = new MySimpleArrayAdapter(this, recordItem);
       listView.setAdapter(arrayAdapter);
    

    with

     ArrayList<String[]> list = new ArrayList<String[]>();
    
     ArrayList array =  (ArrayList) bundle.get("rotaArray");
    
        for(int i = 0; i < array.size(); i++){
    
            String record = array.get(i).toString();
     String[] itemsInRecord = record.split(",");
        list.add(itemsInRecord);  
    
        }
    
     MySimpleArrayAdapter arrayAdapter = new MySimpleArrayAdapter(this, list);  
        listView.setAdapter(arrayAdapter);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
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
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
We're building an app, our first using Rails 3, and we're having to build

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.