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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:07:37+00:00 2026-05-30T15:07:37+00:00

In my app i have a list with custom row,in each row i have

  • 0

In my app i have a list with custom row,in each row i have a button and i want to set all of the buttons to the same listener. when i define a listener to the button (btn in code) my app get crash
this is how i set the list:

private void updateResultsInUi() {         
        lv = getListView();  
        lv.setTextFilterEnabled(true);
        lv.setItemsCanFocus(false);
        lv.setCacheColorHint(0x00000000);

        ItemsAdapter adapter = new ItemsAdapter(this,R.layout.item_row, Catalog.instance());
        lv.setAdapter(adapter);

        lv.setTextFilterEnabled(true);  
        lv.setClickable(true); 

        Button btn = (Button)this.findViewById(R.id.cellbtn);
        btn.setOnClickListener(new OnClickListener() {
          public void onClick(View v) {
              int l = 0;
              l++;
          }
        });

    } 

this is my row xml :

<?xml version="1.0" encoding="utf-8"?>

 <LinearLayout  
     android:layout_height="100dp"
     android:orientation="horizontal" 
     android:layout_width="fill_parent">

     <LinearLayout android:layout_height="wrap_content" 
         android:weightSum="1" android:layout_marginLeft="5dp" 
         android:layout_width="match_parent" 
         android:orientation="horizontal" android:layout_weight="1">

         <LinearLayout android:orientation="vertical" 
             android:layout_height="100dp" 
             android:layout_width="wrap_content">

             <Button android:id="@+id/cellbtn" 
                 android:layout_width="76px" 
                 android:layout_height="37px" android:background="@drawable/hazmanacell" 
                 android:layout_marginTop="20dp"/> 

         </LinearLayout>
         <LinearLayout android:layout_height="wrap_content" 
                     android:orientation="vertical" android:layout_width="0dp" 
                     android:layout_weight="1" android:layout_marginRight="10dp">

                 <TextView android:textSize="14dp" android:layout_weight="0.50" 
                 android:textStyle="bold" android:layout_height="wrap_content" 
                 android:id="@+id/toptext" android:text="stam1" 
                 android:layout_width="fill_parent" 
                 android:gravity="right" android:textColor="@color/black" /> 

                 <TextView android:textSize="12dp" android:layout_weight="0.50" 
                     android:layout_height="wrap_content" 
                     android:text="stam1" android:layout_width="fill_parent" 
                     android:id="@+id/centertext" android:gravity="right" 
                     android:textColor="@color/black" /> 


         </LinearLayout>

    </LinearLayout>
    <ImageView android:id="@+id/imageViewTwitterPic" 
    android:src="@drawable/icon" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" android:gravity="center_vertical" /> 

Edit

In this line :

Button btn = (Button)this.findViewById(R.id.cellbtn);

btn is null,any idea why it’s happen?

  • 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-30T15:07:38+00:00Added an answer on May 30, 2026 at 3:07 pm

    in each row i have a button….In your adapter(ItemsAdapter)

    @Override
        public View getView(final int position, View convertView, ViewGroup parent) { 
    
            Button btn = (Button)view.findViewById(R.id.cellbtn);
            btn.setOnClickListener(new OnClickListener() {
              public void onClick(View v) {
                    Toast.makeText(context,"clicked",Toast.LENGTH_SHORT).show();
              }
            });
        }
    

    in Your row.xml

    <Button
            android:id="@+id/cellbtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:focusable="false"
            android:textColor="#FFFFFF" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the issue: I have a list of App names that I want to
I have an app from where I can get the list of all installed
I'm writing a Blackberry app. I have a custom list field where I can
i have a listView with a custom BaseAdapter.Every list item has a clickable button.
I have developed an Andriod RSS reader app.I have used custom listview to list
I have a custom listView with editText in each row to carry value entered
For an Android app...I have a button on an Activity that calls a custom
I have a list of User Controls in a screen in my WP7 app.
in an app i have an entity that contains a list of other entities
I have an app that has a list of items. My customer prefers 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.