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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:38:33+00:00 2026-06-10T19:38:33+00:00

Here is the activity ShowData.java where i am setting up customized listview.. Now i

  • 0

Here is the activity ShowData.java where i am setting up customized listview.. Now i need to click view on that listview and need to display another activity but throws force close.. It throws error on listview.setAdapter(adapter);

public class ShowData extends Activity
{

    ListView listview;
    Intent intent;
    ArrayList<BeanClass> datalist;
    CustomAdapter adapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);


        listview = (ListView) findViewById(R.id.listView1);

        Intent intent = getIntent();
        datalist = (ArrayList<BeanClass>) intent.getSerializableExtra("list");
        Log.i("Size of ArrayList", "is " +datalist.size());

            adapter = new CustomAdapter(ShowData.this, R.layout.customrow , datalist);

            listview.setAdapter(adapter);
          listview.setOnItemClickListener(new OnItemClickListener() 
            {
        @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) 
            {
                Intent i = new Intent(ShowData.this,DetailActivity.class);
                i.putExtra("datalist", datalist);
                i.putExtra("position", arg2);
                startActivity(i);
            }               
}  
}

Here is the CustomAdapter.java

public class CustomAdapter extends ArrayAdapter<BeanClass>
{
    Context context;
    int layoutResourceId;
    BeanClass bc;
    ArrayList<BeanClass> vbc;

    public CustomAdapter(Context context, int layoutResourceId, ArrayList<BeanClass> vbc) 
    {
        super(context, layoutResourceId, vbc);
        this.context=context;
        this.layoutResourceId=layoutResourceId;
        this.vbc=vbc;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) 
    {
        View row = convertView;
        StringReaderHolder holder;

        if(row == null)
        {
            LayoutInflater inflater = ((Activity)context).getLayoutInflater();
            row = inflater.inflate(layoutResourceId, parent,false);

            holder= new StringReaderHolder();


            holder.mytext1 = (TextView) row.findViewById(R.id.textView1);
            holder.mytext2 = (TextView) row.findViewById(R.id.textView2);
            holder.mytext3 = (TextView) row.findViewById(R.id.textView3);

            row.setTag(holder);
        }
        else
        {
            holder = (StringReaderHolder) row.getTag();
        }

        BeanClass bsObject = vbc.get(position);

        holder.mytext1.setText(bsObject.name);
        holder.mytext2.setText(bsObject.address);
        holder.mytext3.setText(bsObject.phone);


        return row;
    }

    static class StringReaderHolder
    {

        TextView mytext1,mytext2,mytext3;

    }

}

How should i use setOnItemClickListener…??? Thanks…

  • 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-10T19:38:35+00:00Added an answer on June 10, 2026 at 7:38 pm

    In Your getView Method try:

    row.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    Intent i = new Intent(context,DetailActivity.class);
                    i.putExtra("datalist", vbc);
                    i.putExtra("position", position);
                    startActivity(i);
                }
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have my listview activity that works pretty fine but i have an annoying
here i am using an activity in which there is a list view,which I
Here is the short version. I have a Bonus Activity that has 25 image
I am using intent to call activity here and I need to send to
I am a begginer in android,here I have activity that use web service: SoapObject
Im creating a bundle in one activity, then extracting it in another activity here
Hi i currently have an Activity that hosts a tab view, and each tab
I have some code here (my activity class and some class, that extends WebViewClient)
my list view activity, here is were i want to see the list, and
i'm trying to make a webview and listview in a same activity. here's my

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.