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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:27:56+00:00 2026-05-31T04:27:56+00:00

I’m working with expandable listview. In that I need to use click-able imageview. I’ve

  • 0

I’m working with expandable listview. In that I need to use click-able imageview. I’ve tried following but not working. It gives null pointer exception.

here is my xml and listview adapter. I need to put click event on the imageview. from normal activity onclicklistner works perfact, but gives error if you put that in ExpandableListActivity.

Thanks in advance..

public class ExpList extends ExpandableListActivity
{
//    static final String parent_node[] = { "grey", "blue", "yellow", "red" };

String parent_node[];

static final String shades[][] = {
  {
    "lightgrey","#D3D3D3",
    "dimgray","#696969",
    "sgi gray 92","#EAEAEA"
  }, {},
  {
    "dodgerblue 2","#1C86EE",
    "steelblue 2","#5CACEE",
    "powderblue","#B0E0E6"
  }, {}
};

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle)
{
    super.onCreate(icicle);
    setContentView(R.layout.main);   


    LayoutInflater group_inflater = (LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);
     View group_layout = group_inflater.inflate(R.layout.group_row, null);

    ImageView img_call = (ImageView)group_layout.findViewById(R.id.imgcall);

    img_call.setOnClickListener(new OnClickListener() 
    {           
  @Override
  public void onClick(View v) 
      {
        Toast.makeText(getBaseContext(), "clicked...", Toast.LENGTH_SHORT).show();
     }); 

SimpleExpandableListAdapterWithEmptyGroups expListAdapter =
            new SimpleExpandableListAdapterWithEmptyGroups(
                this,
                createGroupList(),                      
                R.layout.group_row,                     
                new String[] { "colorName" },           
                new int[] { R.id.groupname },           
                createChildList(),                      
                R.layout.child_row,                     
                new String[] { "shadeName", "rgb" },    
                new int[] { R.id.childname, R.id.rgb }  
            );
        setListAdapter( expListAdapter );}

And my groupview xml is:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

<ImageView 
    android:src="@drawable/expander_group"
    android:id="@+id/explist_indicator"
    android:layout_width="35px"
    android:layout_height="35px"/>


<ImageView 
    android:src="@drawable/contact_thumbnail"
    android:id="@+id/img_contact_thumbnail"
    android:layout_width="50px"
    android:layout_height="50px"/>

<TextView
    android:id="@+id/groupname"
    android:layout_width="190px"
    android:layout_height="match_parent"
    android:paddingLeft="30px"
    android:textSize="16px"
    android:textStyle="bold" />

<ImageView 
    android:id="@+id/imgcall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/call"
    android:clickable="true" />
</LinearLayout>

EDIT
Now NullPointerException problem is solved. But I came up new problem that onclicklistner is not working. No Toast or anything else written in that section doesn’t execute. I debug program and found that code does not return on onclicklistner when imageview get clicked.

Any idea??

  • 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-31T04:27:58+00:00Added an answer on May 31, 2026 at 4:27 am

    You can try this, hope fully it should work. Just add two line in your xml inside imageview and then write a function to listen the button click in your activity class:

    <ImageView 
        android:id="@+id/imgcall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/call"
        android:clickable="true" 
        android:onClick="onClickHandler"/>
    

    And in your activity class :

    public void onClickHandler (View v) {
        switch (v.getId()) {
            case R.id.imgcall:
                // do what ever you want here ...
                break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a function that will clean a strings' special characters. I do NOT
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is

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.