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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:20:00+00:00 2026-06-07T00:20:00+00:00

Let’s have an example like below: package xliiv.sandbox; import android.app.Activity; import android.os.Bundle; import android.util.Log;

  • 0

Let’s have an example like below:

package xliiv.sandbox;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

public class Double_tablesActivity extends Activity {

    static final String TAG = "MAIN";
    LinearLayout lay;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        LinearLayout lay = new LinearLayout(this);
        this.lay = lay;

        for(int i=0; i<2; i++) {
            boolean heading =  (i == 0) ? true: false; 
            add_table(heading, "" + i);
        }

        this.lay.setOrientation(1);
        setContentView(lay);

    }

    public void add_table(boolean heading, String text) {
        TableLayout t = new TableLayout(this);
        TableRow tr = new TableRow(this);
        TextView tv = new TextView(this);

        tv.setText(text);

        if (heading == true) {
            tv.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    TextView tv = (TextView) v;
                    Log.i(TAG, "onclick: " + tv.getText());

                    //TODO: sort 2nd table denpends on which col of first table was clicked
                    //??
                }
            });
        }

        tr.addView(tv);
        t.addView(tr);
        lay.addView(t);

    }
}

I’d like to sort 2nd table depends on which col was clicked in the 1st table?
Suppose there is a method table.sort(col)..
I found getRootView(), so i could use it and go down to second table but there must be better way, than manually searching..

UPDATE

After midoalageb’s answer here is working version of upper code:

package xliiv.sandbox;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

public class Double_tablesActivity extends Activity {

    static final String TAG = "MAIN";
    LinearLayout lay;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        LinearLayout lay = new LinearLayout(this);
        this.lay = lay;

        for(int i=0; i<2; i++) {
            boolean heading =  (i == 0) ? true: false; 
            add_table(heading, "" + i);
            flipper.setTag("tag" + i);
        }

        this.lay.setOrientation(1);
        setContentView(lay);

    }

    public void add_table(boolean heading, String text) {
        TableLayout t = new TableLayout(this);
        TableRow tr = new TableRow(this);
        TextView tv = new TextView(this);

        tv.setText(text);

        if (heading == true) {
            tv.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    View root = (View) getRootView();
                    View view_by_tag = (View) root.findViewWithTag("tag2");                 
                    Log.i(TAG, "found table: " + flipper);
                }
            });
        }

        tr.addView(tv);
        t.addView(tr);
        lay.addView(t);

    }
}
  • 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-07T00:20:01+00:00Added an answer on June 7, 2026 at 12:20 am

    Since you fill the table from a database, a better implementation is to replace your 2nd table by a ListView and use a SimpleCursorAdapter to fill it.

    SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to)
    

    Each time you press a key in the first table, requery the Cursor of the SimpleCursorAdapter using the relevant ORDER BY SQL query.

    Update: If you do not want to change your layout, you can use View.SetTag to give a unique Tag for your column when you fill it with data, then in the OnClickListener of the first Table, use View.FindViewWithTag to find the column of the second table and then use your sort method to sort this table.

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

Sidebar

Related Questions

Let me explain best with an example. Say you have node class that can
Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
Let's say I have a string like this: var str = /abcd/efgh/ijkl/xxx-1/xxx-2; How do
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Let assume we have two activities. A - main activity, that is home launcher
Let's suppose I have an XML file like this: <?xml version=1.0 encoding=ISO-8859-1?> <MIDIFile> <Event>
Let's say I have table with column 'URL' whrere I store urls like this
Let's say that I have a set of relations that looks like this: relations

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.