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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:37:28+00:00 2026-06-02T22:37:28+00:00

i want custome ListView with 2 textbox whene in First i can show number

  • 0

i want custome ListView with 2 textbox whene in First i can show number and in another i can show its missed call number , received or outgoing number,with date i am able to show date and call type in Secod Line of ListView but when i try to show number it gives following error .

04-30 16:38:02.764: E/AndroidRuntime(7312): FATAL EXCEPTION: main
04-30 16:38:02.764: E/AndroidRuntime(7312): java.lang.ArrayIndexOutOfBoundsException
04-30 16:38:02.764: E/AndroidRuntime(7312): at com.custom.ListViewAdapter.getView  (ListViewAdapter.java:64)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.widget.AbsListView.obtainView(AbsListView.java:2203)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.widget.ListView.measureHeightOfChildren(ListView.java:1204)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.widget.ListView.onMeasure(ListView.java:1115)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.view.View.measure(View.java:8339)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:381)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.view.View.measure(View.java:8339)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at   android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.view.View.measure(View.java:8339)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.view.View.measure(View.java:8339)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.view.View.measure(View.java:8339)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.view.ViewRoot.performTraversals(ViewRoot.java:801)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.os.Looper.loop(Looper.java:123)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at java.lang.reflect.Method.invokeNative(Native Method)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at java.lang.reflect.Method.invoke(Method.java:521)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:870)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
04-30 16:38:02.764: E/AndroidRuntime(7312):     at dalvik.system.NativeStart.main(Native Method)

Here , i have converted List to String[] but i am able to get output if i write
lviewAdapter = new ListViewAdapter(this, timeArray, timeArray); in which both prints call Type and date but when i write
lviewAdapter = new ListViewAdapter(this, timeArray, timeArray);
it Gives ArrayIndexoutOfBoundException

ListView2Activity.java

import java.sql.Date;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.CallLog;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class ListView2Activity extends Activity implements OnItemClickListener
{
 /** Called when the activity is first created. */

ListView lview;
ListViewAdapter lviewAdapter;
List<String> dir;
List<String> num;
String[] numArray ;
String[] timeArray;
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main); 
    dir = new ArrayList<String>();
    num = new ArrayList<String>();
    Cursor managedCursor = managedQuery( CallLog.Calls.CONTENT_URI,null, null,null, null);
    int number = managedCursor.getColumnIndex( CallLog.Calls.NUMBER ); 
    int type = managedCursor.getColumnIndex( CallLog.Calls.TYPE );
    int date = managedCursor.getColumnIndex( CallLog.Calls.DATE);

    Log.d("tag","call details");
    while ( managedCursor.moveToNext() ) 
    {
    String phNumber = managedCursor.getString( number );
    num.add(phNumber);

    String callType = managedCursor.getString( type );
    String callDate = managedCursor.getString( date );
    Date callDayTime = new Date(Long.valueOf(callDate));


    int dircode = Integer.parseInt( callType );
    switch( dircode )
    {
    case CallLog.Calls.OUTGOING_TYPE:
        dir.add("OUTGOING" + " , "+ callDayTime);

        break;
    case CallLog.Calls.INCOMING_TYPE:
        dir.add("INCOMING"+ " , "+ callDayTime);


        break;
    case CallLog.Calls.MISSED_TYPE:
        dir.add("MISSED"+  " , "+ callDayTime); 
        break;
    }// switch end
    Log.d("tag",phNumber +"," + dir );

    } // while end


     numArray = new String[num.size()];
    for (int i = 0; i < num.size(); i++) 
    {
        numArray[i] = num.get(i);  
    //  Log.i("tag", "in array :" + num[i]);
    } // for end

     timeArray = new String[dir.size()];
    for (int j = 0; j < dir.size(); j++) {
        timeArray[j] = dir.get(j);  
    } // for end

    managedCursor.close();

    lview = (ListView) findViewById(R.id.listView2);
    lviewAdapter = new ListViewAdapter(this, numArray, timeArray);

    System.out.println("adapter => "+lviewAdapter.getCount());

    lview.setAdapter(lviewAdapter);

    lview.setOnItemClickListener(this);
} // create end

public void onItemClick(AdapterView<?> arg0, View arg1, int position, long id) 
{
    // TODO Auto-generated method stub
    Toast.makeText(this,"Title => "+numArray[position]+"=> n Description"+timeArray[position], Toast.LENGTH_SHORT).show();
}}

ListViewAdapter.java

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListViewAdapter extends BaseAdapter
{
Activity context;
String title[];
String description[];

public ListViewAdapter(Activity context, String[] title, String[] description) {
    super();
    this.context = context;
    this.title = title;
    this.description = description;
}

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

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

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

private class ViewHolder {
    TextView txtViewTitle;
    TextView txtViewDescription;
}

public View getView(int position, View convertView, ViewGroup parent)
{
    // TODO Auto-generated method stub
    ViewHolder holder;
    LayoutInflater inflater =  context.getLayoutInflater();

    if (convertView == null)
    {
        convertView = inflater.inflate(R.layout.listitem_row, null);
        holder = new ViewHolder();
        holder.txtViewTitle = (TextView) convertView.findViewById(R.id.textView1);
        holder.txtViewDescription = (TextView) convertView.findViewById(R.id.textView2);
        convertView.setTag(holder);
    }
    else
    {
        holder = (ViewHolder) convertView.getTag();
    }

    holder.txtViewTitle.setText(title[position]);
    holder.txtViewDescription.setText(description[position]);

return convertView;
}
}
  • 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-02T22:37:30+00:00Added an answer on June 2, 2026 at 10:37 pm

    The above code is working well i just copy and paste it and run this code and get the following result.

    enter image description here

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

Sidebar

Related Questions

My Custom ListView Adapter class like this. I want to get the index number
I have a listView with custom objects defined by the xml-layout below. I want
I have a custom adapter for my ListView which has multiple TextViews. I want
I want to display animated GIF images in my custom listview.my GIF image is
I want to do custom sorting on a ListView which has a DataTable as
I have a ListView which has custom elements inside of it. I want to
I want my ListView to look like a notepad, ie with a horizontal lines
In android application i have a custom listview and sqlite database. I want to
i am developing one contact application . I want to show contact image to
Actually I have created a custom ListView . I want to add items to

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.