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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:23:06+00:00 2026-06-08T19:23:06+00:00

This is a double question about using interfaces – namely onclickListener (and related) within

  • 0

This is a double question about using interfaces – namely onclickListener (and related) within an Activity.

  1. onCreate should be short – so says the documentation – but if I have lots and lots of views all of which have onClickListeners it can get quite long. I’m worried this will cause the UI thread to timeout. Is this a problem?
  2. Is there a best way to use onClickListener? By which I mean, is it better for the Activity to implement onCLickListener and then have a very long onClick() method? Or do the following:

    mView.setOnClickListener(new OnClickListener(){
       ...
     });
    

for each View? Does it really make any difference?

  • 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-08T19:23:07+00:00Added an answer on June 8, 2026 at 7:23 pm
    1. They mean “short” in that don’t do anything that takes a long time to process in onCreate(). Anything like math computations, networks or database access, extremely large bitmaps inflations should be done in a thread. The only overhead that setting an onClickListener to a view is calling a method, setting a reference, and usually creating an object. If object creation does any of the aforementioned things, then it would be best to pre-load the object before creating it.

    2. There’s no real difference. What you choose depends entirely on your implentation and coding stye. Using an anonymous object like you showed is kind of like a “set-and-forget” style way of doing it. It’s suitable if the action is unique to the button. Creating a whole new class that that implements onClickListener() would be required if there needs to be a state that persists with each click. That way, you create the object once and set all the necessary views to the single object. It may also be useful to do it in that fashion if many views do the same action when clicked.

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

Sidebar

Related Questions

This question is about the threshold at which Math.Floor(double) and Math.Ceiling(double) decide to give
From this question I learned Double.NaN is not equal to itself. I was verifying
This is probably a naive question - but I want to double check to
This may seem like an absurd question, however thought I best double check beforehand.
This may seem like a realy basic question but... How do you use double
While answering this question, I got these confusing results: double d = 0.49999999999999990d; //output
Now the question is pretty hard. Now this is my main list List<List<KeyValuePair<string, double>>>
Sorry for the double post, I will update this question if I can't get
(This question should probably be answered with a reference to Stroustrup.) It seems extremely
This is really a double question, my two end goals having answers to: What

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.