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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:30:44+00:00 2026-06-02T05:30:44+00:00

I build a UI based on JSON Objects sent in a method. Each time

  • 0

I build a UI based on JSON Objects sent in a method. Each time the method runs, a new row is added to the UI. I need my chartsButtonListener to be able to access the JSONObject question.

public void buildQuestions(JSONObject question) throws JSONException {
    LayoutInflater inflater = (LayoutInflater) getActivity().
    getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    questionContainer = (TableLayout) mainLayout.findViewById(R.id.questionContainer);

    View questionBox = inflater.inflate(R.layout.question, null);
    questionBox.setId(Integer.parseInt(question.getString("id")));
    TextView title = (TextView) questionBox.findViewById(R.id.questionTextView);
    title.setText(question.getString("title"));

    //omitted code for verbosity

    Button chartsButton = (Button) questionBox.findViewById(R.id.chartsButton);

    Button submitButton = (Button) questionBox.findViewById(R.id.submitButton);
    chartsButton.setOnClickListener(chartsListener);
    submitButton.setOnClickListener(submitListener);

    TableRow tr = (TableRow) questionBox;
    TableLayout.LayoutParams trParams = new TableLayout.LayoutParams(
    TableLayout.LayoutParams.MATCH_PARENT,
    TableLayout.LayoutParams.MATCH_PARENT);
    trParams.setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
    tr.setLayoutParams(trParams);   
    LinearLayout progressRow = (LinearLayout) mainLayout.findViewById(R.id.progressRow);
    progressRow.setVisibility(View.GONE);
    questionContainer.addView(tr);
}

public OnClickListener chartsListener = new OnClickListener() {
    public void onClick(View v) {
        Intent chart = new Intent();
        chart.setClass(getActivity(), Chart.class);
        Log.v("", v.getParent().getClass().toString());//returns the TableRow
        startActivity(chart);
    }   
};

I am familiar with put extra, but it would be best if I could simply pass the question object to the listener directly, so I could then forward it along to the Intent. Any suggestions?

  • 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-02T05:30:45+00:00Added an answer on June 2, 2026 at 5:30 am

    You can use View.setTag(Object) to associate any arbitrary object to a View.

    chartsButton.setTag(question);

    And in your onClick, you can do:
    Question q = (Question) v.getTag();

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

Sidebar

Related Questions

I need to build a java based JSON data API that will be accessed
I need to build a PDF based on FDF. I saw that Adobe has
I need to build a rule-based system that can be run and developed in
I am trying to build a REST & json based WCF service that takes
I'm new to JQuery and trying to use it to dynamically build HTML based
Noob WCF/REST question here! I need to build a simple web service (one method
I have a WorldWind application build based on the Java SDK. It has a
I am installing a pre-build php-based web application for a client. Unfortunately the application
We build complicated console-based tools that produce a lot of commentary on the console.
Basically I want to build a website based on some original content, the content

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.