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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:51:06+00:00 2026-06-09T18:51:06+00:00

I got the following onClick command for a button. But when i call it

  • 0

I got the following onClick command for a button. But when i call it nothing appears
CODE:

public void onClick(View v) {

Log.d("debug", "before loadGutschein");
                    loadGutschein();
                    ViewFlipperVino.setDisplayedChild(3);
                    layout_number = 3;
                    Log.d("debug", "after loadGutschein");
                    bottomAudioLogosLayout.postDelayed(new Runnable() {

                        DisplayMetrics metrics = getActivity().getResources().getDisplayMetrics();
                        int width = metrics.widthPixels;


                        @Override
                        public void run() {
                            Log.d("debug", "couponsout=" + coupons);

                            if (coupons != null) {
                                int coupSize = coupons.size();
                                final int itemWidth = (width / coupSize) - 5;
                                for (int i = 0; i < coupSize; i++) {
                                    Coupon coupon = coupons.get(i);
                                    if (coupon.getImage() != null) {
                                        final CheckBox cb = new CheckBox(getActivity());
                                        final ImageView iv = new ImageView(getActivity());
                                        iv.setScaleType(ScaleType.CENTER_INSIDE);
                                        LayoutParams linearLayoutParams = new LayoutParams();
                                        iv.setLayoutParams(linearLayoutParams);
                                        cb.setLayoutParams(linearLayoutParams);
                                        bottomAudioLogosLayout.addView(iv);
                                        bottomAudioLogosLayout.addView(cb);
                                        ImageUtil.loadImage(coupon.getImage(), iv, -1, -1, "", false);
                                    }
                                }
                            }

                        }
                    }, 200);
}

============LoadGutschein Method:

   private void loadGutschein() {
    ServiceProxy.createWebServiceTask(getActivity(), new RemoteCallListener() {

        @Override
        public void onRemoteCallError(String response) {
            Log.e("error", "onRemoteCallError is ==>" + response);
        }

        @Override
        public void onRemoteCallComplete(Object response) {
            Log.d("debug", "response is = " + response + "\t" + response.getClass());
            coupons = (Coupons) response;
            Log.d("debug", "coupons = " + coupons);


        }

        @Override
        public void onNoInternetError() {
            Log.e("error", "onNoInternetError");
        }

        @Override
        public void onNoAccess() {
            Log.e("error", "onNoAccess");
        }
    }, true, true).invokeGetCoupons();
}

=========MY LOGCAT LOG:

08-13 14:36:11.382: D/debug(17576): gutscheinName= e
08-13 14:36:11.382: D/debug(17576): gutscheinHN= d
08-13 14:36:11.382: D/debug(17576): gutscheinCash= 50
08-13 14:36:11.382: D/debug(17576): before loadGutschein
08-13 14:36:11.445: D/debug(17576): after loadGutschein
08-13 14:36:11.515: I/WEB-SERVER-CLIENT GET :(17576):     http://developer.weinco.de/api/v1/getCoupons?
08-13 14:36:11.648: D/debug(17576): couponsout=null
08-13 14:36:11.742: D/debug(17576): response is = [Coupon [Name=Rabatt, Code=321, GueltigBis=2014-09-01, Typ=absolut, Wert=10, GueltigAb=2011-09-01, Gueltig=alle]] class com.weinco.webservice.entity.Coupons
08-13 14:36:11.742: D/debug(17576): coupons = [Coupon [Name=Rabatt, Code=321, GueltigBis=2014-09-01, Typ=absolut, Wert=10, GueltigAb=2011-09-01, Gueltig=alle]]

I don’t get why the coupons value in the postDelayed (couponsout in logcat) is null, if coupons from the webservice takes the valures of the response. Any ideea how i could work this out?

  • 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-09T18:51:07+00:00Added an answer on June 9, 2026 at 6:51 pm

    I don’t get why the coupons value in the postDelayed (couponsout in
    logcat) is null, if coupons from the webservice takes the valures of
    the response.

    I think the problem appears because of the way you use the data returned from the webservice.
    In the onClick callback you start the task of getting the data(and set the results in the callback for the task complete event onRemoteCallComplete) and then schedule a Runnable to be run after 200ms(maybe you could explain why you post the Runnable after exactly 200ms). What if the task takes more then 200 ms, wouldn’t posting a Runnable that depends on the coupons variable fail because the task to get new data hasn’t yet completed?

    Probably you don’t initialize coupons so there is a good chance of it being null at the time when the Runnable is run. The code in the Runnable‘s run method should be run only when you are certain that the process of getting data from the webservice is finished(the onRemoteCallComplete seems like a good place but I don’t know your full code).

    Also, you should give some sizes to your LayoutParams and not just instantiate it, for example:

    LayoutParams linearLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried the following code .. btnRemoveItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View
I got following code from net and it looks everything is proper but i'm
I got following code in an XHTML-document and every browser saysit is malformed :(
I've got following code in my AsyncTask. The only thing I want the AsyncTask
I've got the following list item: <li> <input value=someRadioButton name=ctl00$mainContent$group type=radio id=ctl00_mainContent_somelRadioButton onclick=showSomeInfo() />
Let say I got the following button : <asp:Button ID=btnSearch runat=server /> and the
I've got the following code on my page, and what i'm trying to do
I finally got some parts working here: http://jsfiddle.net/trXBr/5/ but when I put the code
I've got a VEMap control with the following relevant bits of code: map =
I had the following (minor but nagging!) problem: I've got a PreferenceActivity with a

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.