0

I would ask you a quick question.

In my layout, I have added a button with text "Go to store":

<Button
    android:id="@+id/go_to_store"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Go to store"/>

I got the details from Json response:

JSONObject baseJsonResponse = new JSONObject(SAMPLE_JSON_RESPONSE);
            JSONArray couponCategoryArray = baseJsonResponse.getJSONArray("results");

            for (int i = 0; i < couponCategoryArray.length(); i++) {

                JSONObject currentEarthquake = couponCategoryArray.getJSONObject(i);
                JSONObject properties = currentEarthquake.getJSONObject("campaign");
                String name = properties.getString("name");

                String promo_code = currentEarthquake.getString("promocode");

                String goto_store = currentEarthquake.getString("goto_link");

                CouponCategory couponCategory = new CouponCategory(name, promo_code, goto_store);
                couponcategory.add(couponCategory);

            }

and

Button descriptionTextView = (Button) listItemView.findViewById(R.id.go_to_store);
    descriptionTextView.setText(currentCouponCategory.getDescription());
    descriptionTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(currentCouponCategory.getDescription()));
            getContext().startActivity(browserIntent);
        }
    });

And the coupon Category is:

private String mStoreName;

private String mPromoCode;

private String mGotoStore;

public CouponCategory(String storeName, String promoCode, String gotoStore) {
    mStoreName = storeName;
    mPromoCode = promoCode;
    mGotoStore = gotoStore;
}

//** Get the Magnitude of the earthquake*/
public String getStoreName() { return mStoreName; }

public String getPromoCode() { return mPromoCode; }

public String getDescription() { return mGotoStore; }}

JSON response:

\"image\":\"http://cdn.admitad.com/campaign/images/2015/03/13/26eb60d1e6b5d4ec7c92062e5d1e8430.jpg\",\n" +
        "         \"species\":\"promocode\",\n" +
        "         \"categories\":[\n" +
        "            {\n" +
        "               \"id\":8,\n" +
        "               \"name\":\"Компьютеры и электроника\"\n" +
        "            }\n" +
        "         ],\n" +
        "         \"name\":\"Banggood 10% OFF Site Wide Coupon\",\n" +
        "         \"promocode\":\"BGAFF10OFF\",\n" +
        "         \"frameset_link\":\"\",\n" +
        "         \"goto_link\":\"https://ad.admitad.com/g/tx4zgk4gbq2e4b3978f86213826a88/?i=3\"\n" +

I am trying to edit part of the code but I continue to see, in the button, the link of the store got from Json: https://ibb.co/ZTQkwH5

How could I fix it?

Thank you for your help.

14
  • please don't link to your code as off-site resources or images, please include everything relevant as text in your question, only use images to describe what you can't describe with text Commented Jul 21, 2020 at 12:22
  • I edit immediately, sorry. Commented Jul 21, 2020 at 12:23
  • no problem :) the reason why it's bad is because it doesn't help others who might have the same problem in future, as the code won't be searchable to them, as well as links and resources changing, if someone in future has the same problem as you and the link has changed, then they won't get an answer. that's why it's best to include everything here Commented Jul 21, 2020 at 12:24
  • You are right. I changed it. Commented Jul 21, 2020 at 12:25
  • 1
    then make it go to store descriptionTextView.setText("Go to store") Commented Jul 21, 2020 at 12:41

1 Answer 1

1

Use this-->

descriptionTextView.setText("Go to store")

instead of -->

descriptionTextView.setText(currentCouponCategory.getStoreName());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.