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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:21:36+00:00 2026-06-01T12:21:36+00:00

I have an Android application with a ListView in it, the ListView will setup

  • 0

I have an Android application with a ListView in it, the ListView will setup fine but now I want a image in the ListView to be clickable. I do this by using 2 classes, the Activity class (parent) and an ArrayAdapter to fill the list. In the ArrayAdapter I implement a OnClickListener for the image in the list that I want to be clickable.

So far it all works.

But now I want to run a function from the activity class when the onClick, for the image in the list, is run but I do not know how. Below are the 2 classes that I use.

First the Activity class:

public class parent_class extends Activity implements OnClickListener, OnItemClickListener
{
    child_class_list myList;
    ListView myListView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // setup the Homelist data
        myList     = new child_class_list (this, Group_Names, Group_Dates);
        myListView = (ListView) findViewById(R.id.list);

        // set the HomeList
        myListView.setAdapter( myList );
        myListView.setOnItemClickListener(this);
    }

    void function_to_run()
    {
        // I want to run this function from the LiscView Onclick
    }

    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) 
    {
        // do something
    }
}

And the ArrayAdapter from where I want to call a function from the Activity class:

public class child_class_list extends ArrayAdapter<String>
{
    // private
    private final Context context;
    private String[]        mName;
    private String[]        mDate;

    public child_class_list (Context context, String[] Name, String[] Date) 
    {
        super(context, R.layout.l_home, GroupName);
        this.context        = context;
        this.mName      = Name;
        this.mDate  = Date;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) 
    {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rowView = inflater.inflate(R.layout.l_home, parent, false);

        ImageView selectable_image = (ImageView) rowView.findViewById(R.id.l_selectable_image);
        selectable_image.setOnClickListener(new OnClickListener()
        {
            public void onClick(View v) 
            {
                // I want to run the function_to_run() function from the parant class here
            }
        }
        );

        // get the textID's
        TextView tvName = (TextView) rowView.findViewById(R.id.l_name);
        TextView tvDate = (TextView) rowView.findViewById(R.id.l_date);

        // set the text
        tvName.setText      (mName[position]);
        tvDate.setText  (mDate[position]);

        return rowView;
    }
}

If anyone knows how to run the function in the activity class from the arrayadapter or how to set the image onClickListener in the Activity Class I would greatly apriciate the help.

  • 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-01T12:21:37+00:00Added an answer on June 1, 2026 at 12:21 pm

    Inside onClick() Do something like this:

    ((ParentClass) context).functionToRun();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a ListView in my android application. But the problem is that
I have been developing Android application, and I have one question - ListView uses
I have a ListView in my android application. If I flick up/down the ListView,
Hi am working on an android application. And am using a listview in some
i am building an android application but i have some questions about the memory
I'm developing one android application in which I'm using one customized ListView which extends
I have a layouting problem with my android application: I have a Listview consiting
I am doing an contact list android application but i have a small problem
I am doing an contact list android application but i have a small problem
I am using ListView in my application. For each listitem I have to keep

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.