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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:47:00+00:00 2026-05-30T11:47:00+00:00

i need to display some records in listview but when i am calling services

  • 0

i need to display some records in listview but when i am calling services it get me error in adapter.so can you tell me how can i correct it?i got Arrayindexoutofbound in USERNAME. i have also check main activity but there are no problem at all.this code are previosly working good.but now it raise issue….

package com.RecordingAppDotnet;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;

import com.Sharedpreferance.GMailSender;

public class LogListAdapter extends BaseAdapter
{

    public String ScoreID[];
    public String Activityname[];
    public String UserName[];
    public String PlayedDate[];
    public String UserComment[];
    public String Score[];
    public int int_spnr_choose_item_first_or_sec;
    public Activity context;
    public LayoutInflater inflater;

    public LogListAdapter(Activity context,String[] ScoreID,String Activityname[],String UserName[],String PlayedDate[],String UserComment[],String Score[],int int_spnr_choose_item_first_or_sec) {
        super();

        this.context = context;
        this.ScoreID = ScoreID;
        this.Activityname = Activityname;
        this.UserName = UserName;
        this.PlayedDate = PlayedDate;
        this.UserComment= UserComment;
        this.Score = Score;
        this.int_spnr_choose_item_first_or_sec = int_spnr_choose_item_first_or_sec;
        this.inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return Activityname.length;
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }

    public static class ViewHolder
    {
        TextView log_Activity,log_username,log_playdate,log_score;
        Button edit_comment;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub

        ViewHolder holder;
        if(convertView==null)
        {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.log_activity_row, null);
            holder.log_Activity = (TextView) convertView.findViewById(R.id.log_Activity_name);
            holder.log_username = (TextView) convertView.findViewById(R.id.log_Username);
            holder.log_playdate = (TextView) convertView.findViewById(R.id.log_PlayDate);
            holder.log_score = (TextView) convertView.findViewById(R.id.log_Score);
            holder.edit_comment = (Button)convertView.findViewById(R.id.log_comment_btn);




            convertView.setTag(holder);
        }
        else
            holder=(ViewHolder)convertView.getTag();
        holder.log_Activity.setText(Activityname[position]);
        holder.log_username.setText(UserName[position]);
        holder.log_playdate.setText(PlayedDate[position]);
        holder.log_score.setText(Score[position]);
        //final Intent editcommentIntent = new Intent(context,LogList.class);
        holder.edit_comment.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {



                final Dialog dialog = new Dialog(context);
                dialog.setContentView(R.layout.comment);
                dialog.setTitle("Put your Comment");
                dialog.setCancelable(true);

                final EditText cmment_comment_edtx;
                Button cmt_btn_ok,cmt_cacel;
                cmment_comment_edtx =(EditText)dialog.findViewById(R.id.cmment_comment_edtx);
                //UserComment[position].replaceAll("\\%0A", "");
                UserComment[position] = URLDecoder.decode(UserComment[position].toString());
                cmment_comment_edtx.setText(UserComment[position].toString());
                cmt_btn_ok = (Button)dialog.findViewById(R.id.cmt_btn_ok);
                cmt_cacel = (Button)dialog.findViewById(R.id.cmt_cacel);
                cmment_comment_edtx.setOnEditorActionListener(new OnEditorActionListener(){ 

                    @Override
                    public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
                         return false;
                    }

                 });

                cmt_btn_ok.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                            try
                            {
                            String Comment = cmment_comment_edtx.getText().toString().trim();

                            String query = URLEncoder.encode(Comment, "utf-8");
                                try
                                {                                         //Webservices/Service.asmx/UpdateLogComment?ScoreId=string&MachineName=string&UserComment=string
                                    String sourceUrl1 = "URL/Service.asmx/UpdateLogComment?ScoreId="+ScoreID[position]+"&MachineName="+Machinelist.str_Machinename+"&UserComment="+query+"";
                                    URL sourceUrl = new URL(sourceUrl1);
                                    SAXParserFactory spf = SAXParserFactory.newInstance();
                                    SAXParser sp = spf.newSAXParser();
                                    XMLReader xr = sp.getXMLReader();
                                    commentHandler dataHandler = new commentHandler();
                                    xr.setContentHandler(dataHandler);
                                    xr.parse(new InputSource(sourceUrl.openStream()));
                                    commentDataset dataset = dataHandler.getParsedcomment_DataSet();

                                    String flag_sucess_send_commnt = dataset.getboolean1();
                                    if(flag_sucess_send_commnt.equalsIgnoreCase("true"))
                                    { 
                                        Toast.makeText(context, "Comment added Successfully.",Toast.LENGTH_LONG).show();
                                        dialog.cancel();
                                        LogList.lview.setVisibility(View.INVISIBLE);

                                    }
                                    else
                                    {
                                        Toast.makeText(context, "Comment not Update,Please Try Again", Toast.LENGTH_LONG).show();
                                    }
                                }catch (Exception e) {
                                    e.printStackTrace();
                                }

                    }catch (Exception e) {
                        Writer writer = new StringWriter();
                        PrintWriter printWriter = new PrintWriter(writer);
                        e.printStackTrace(printWriter);
                        String s = writer.toString();

                        } catch (Exception ex) {   

                        } 
                    }}
                });

                cmt_cacel.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        dialog.cancel();
                    }
                });
                dialog.show();


            }
        });


        return convertView;
    } 

}

ERROR :

02-28 16:25:54.082: ERROR/AndroidRuntime(3374): FATAL EXCEPTION: main
02-28 16:25:54.082: ERROR/AndroidRuntime(3374): java.lang.ArrayIndexOutOfBoundsException
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at com.RecordingAppDotnet.LogListAdapter.getView(LogListAdapter.java:107)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.widget.AbsListView.obtainView(AbsListView.java:1428)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.widget.ListView.measureHeightOfChildren(ListView.java:1265)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.widget.ListView.onMeasure(ListView.java:1128)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.view.View.measure(View.java:8553)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:581)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:365)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.view.View.measure(View.java:8553)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:581)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:365)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.view.View.measure(View.java:8553)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:581)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:365)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.view.View.measure(View.java:8553)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3261)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.view.View.measure(View.java:8553)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3261)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.view.View.measure(View.java:8553)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.view.ViewRoot.performTraversals(ViewRoot.java:915)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1991)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.os.Looper.loop(Looper.java:150)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at android.app.ActivityThread.main(ActivityThread.java:4385)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at java.lang.reflect.Method.invokeNative(Native Method)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at java.lang.reflect.Method.invoke(Method.java:507)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
02-28 16:25:54.082: ERROR/AndroidRuntime(3374):     at dalvik.system.NativeStart.main(Native Method)
  • 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-30T11:47:01+00:00Added an answer on May 30, 2026 at 11:47 am

    Are you sure that Activityname and Username have the same sizes? It seems that Activityname.length > Username.length

    EDIT: Add this in your constructor to check array sizes

        Log.d("TEST", "Activityname size = " + Activityname.length );
        Log.d("TEST", "UserName size     = " + UserName.length );
        Log.d("TEST", "PlayedDate size   = " + PlayedDate.length );
        Log.d("TEST", "UserComment size  = " + UserComment.length );
        Log.d("TEST", "Score size        = " + Score.length );
    

    EDIT2: Don’t be so sure!

    According to Android documentation, a new array will be created by the collection.toArray(Object[]) method if the size of the collection is greater than the argument array. So, str_arr_ActivityName and str_arr_UserName may have a size different of ActivityName.size().

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

Sidebar

Related Questions

I am running a Tomcat application, and I need to display some time values.
Need some help assigning a mouseover event to display some icons that start out
Hi I need to create a module in drupal to display some data, not
At some point I need to display a disabled (greyed out by disabled=disabled attribute)
I display set of images(small). I need to show the larger image(300*300) at some
I need to display an error message on rejecting a drop in my application.
I need to display additional information, like a tooltip, but it's a lot of
I need to fetch images and some other data from server and then display
I am trying to get some data stored in a database that i can
As need to display Records in grid view in (ASP.NET) web site. and for

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.