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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:08:32+00:00 2026-06-10T22:08:32+00:00

I am creating a table with dynamic custom table rows. I need to get

  • 0

I am creating a table with dynamic custom table rows. I need to get the id in the activity class.

main_Activity–>MyTableLayoutView–>MyTableRow

My Question is, how do i get the id of the cell that was clicked in the table (TextViews) to the main_Activiy.

MyTableRowView:

    public void addRow(String[] data, int[] rowId) {
    for (int i = 0; i < data.length; i++) {
        TextView tv = parseTextView(data[i]);
        tv.setId(rowId[i]);
        tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                TextView tv2 = (TextView) v;
                clickedText = tv2.getText().toString();
                Debug.debugMsg(clickedText + " " + tv2.getId());
            }
        });
        this.addView(tv);
    }
}

As far as I can get is getting the id from the TablerowView class, but I need it to be in Activity class, Please if anyone can enlighten me. Thanks in advance.

Activity class:

    private void showTables() {
    db.open();
    db.importDb();// TODO
    table = new TableLayoutView(this,Converter.toArrayListStringArray(db.getDbTablesForChoose()));
    table.addDataListArray(Converter.toArrayListStringArray(db.getDbTablesForChoose()),true);
    llChooseSQLTable.addView(table);
}

TableLayoutView:

    public void addDataListArray(ArrayList<String[]> data, boolean header) {

    for (int i = 0; i < ROW_NUMBERS; i++) {
        TableRowView tableRow = new TableRowView(context);

        tableRow.setLayoutParams(new LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

        tableRow.addRow(data.get(i),idHandler.getNextIdsRow());//idHandles passes unique id.
        this.addView(tableRow); 
    }
}
  • 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-10T22:08:33+00:00Added an answer on June 10, 2026 at 10:08 pm

    It seems like you are able to get the ID from your code above. If your primary concern is propagating that id from the view back up to the parent class then you could do it in multiple ways. One way is to get the context of the view then cast it to the specific activity and call a function within that activity, e.g. within the onClick() operation:

    public void onClick(View v) {
      ((MyActivity)v.getContext()).insertNotificationMethod(v.getId());
    }
    

    Where your activity is called MyActivity and you implement a method called insertNotificationmethod which takes an integer. This would work only if this view is always within this function, and even then it is a rather crude way to do it.

    You could also just directly call it within the onClick() method using:

    MyActivity.this.insertNotificationMethod(v.getId());
    

    However, this way of doing things would limit this view to only be useful within this particular activity.

    For a more generic way, you could BroadcastReceivers which may be a little more complicated that you would like. For more information about those you could check out the Android documentation here: http://developer.android.com/reference/android/content/BroadcastReceiver.html

    Hopefully that helps.

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

Sidebar

Related Questions

What im doing is I have a dynamic table and creating rows which all
I would like to create dynamic table in android (custom number of rows and
I am making a dynamic table that will add rows whenever the add row
I'm creating a dynamic form builder where table rows can be dragged, dropped, reordered
So I was thinking about creating a dynamic sql question, meaning that i want
I am creating a dynamic button in a custom class, outside of the .aspx
I'm having difficulties with creating dynamic table of SDL_Surface. Take a look at that
Hi i am developing android application. I that i have creating the dynamic table
I am using smarty and creating a dynamic html table that has radio buttons
I am creating a dynamic table of three columns and multiple rows. I want

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.