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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:12:25+00:00 2026-05-31T13:12:25+00:00

I am working on Custom ListView for an assignment given to me. I have

  • 0

I am working on Custom ListView for an assignment given to me. I have worked out a custom list view by using Base Adapter.
I have a Button in the view by clicking on which I want new activity to be started. But I am getting error on run time. Please note that BUTTON is not the part of the listview, I mean its not repeating, Its placed only once at the top of the layout with Listview included.

public class mainActivity2 extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.item_list);

    ArrayList<ItemInfo> items = GetSearchResults();
    final ListView lv1 = (ListView) findViewById(R.id.mylistview);
   if(lv1==null){

        Log.d("error","ListView is null");
    }

    lv1.setAdapter(new itemBaseAdapter(this, items));
    final Button btnShowCart = (Button) findViewById(R.id.shCart);
    btnShowCart.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
              Intent myIntent = new Intent(v.getContext(), Cart.class);
               startActivity(myIntent);         

        }
    });   


}

private ArrayList<ItemInfo> GetSearchResults() {

    ArrayList<ItemInfo> items=new ArrayList<ItemInfo>();
    items.add(new ItemInfo("pizza",R.drawable.icon,15));
    items.add(new ItemInfo("chicken",R.drawable.icon,10));
    items.add(new ItemInfo("slice",R.drawable.icon,12));
    items.add(new ItemInfo("hoha",R.drawable.icon,20));

    return items;
}

}

StartActivity(myIntent) is the line I am getting error at run time.
Here is the code to it, I will be grateful if somebody shed light on the problem.

  • 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-31T13:12:26+00:00Added an answer on May 31, 2026 at 1:12 pm

    Did you add Cart.class to manifest file? What is error log?

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

Sidebar

Related Questions

We have created custom listview by using the Base adapter. List view contains Text
I have a ListView with a custom view rendered by an adapter. It contains
I'm working on application where I have a custom made List View, with image
I have a nicely working custom CursorAdapter with customized ListView. This view allows the
HI Guyz i have created a sectioned custom listview using baseadapter its working fine
I have a Listview with custom cursor adapter. I'm trying to prevent input in
I have a custom listview which display an image, textview and radio button. I
i have a ListView with a custom Servizio object in every row. I'm using
I have a ListView that is being populated with a custom adapter. I have
I have a custom adapter for ListView and I need to return LinearLayout from

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.