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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:58:30+00:00 2026-05-20T17:58:30+00:00

In list view the position of particular row can easily be determined through array

  • 0

In list view the position of particular row can easily be determined through array adapter and then by using onlistitemclick method we can have that value in toast message

but how can we get position or id of any particular text view(when it is clicked) from table view where table rows are generating dynamically through xml parser..
where column names are id, name and class.
id is auto incremented..
pls suggest.

the code is

try {

        /** Handling XML */
        SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParser sp = spf.newSAXParser();
        XMLReader xr = sp.getXMLReader();


        URL sourceUrl = new URL("http://ip-address/test/player.xml");


        MyXMLHandler myXMLHandler = new MyXMLHandler();
        xr.setContentHandler(myXMLHandler);
        xr.parse(new InputSource(sourceUrl.openStream()));

        } catch (Exception e) {
            System.out.println("XML Pasing Excpetion = " + e);
        }


    DataList dataList = XMLHandler.DataList;


    name = new TextView[dataList.getName().size()];
    class = new TextView[dataList.getName().size()];

    /** Set the result text in textview and add it to layout */
    for (int i = 0; i < DataList.getName().size(); i++) {

         TableRow tr = new TableRow(this);
         tr.setId(100+i);
         tr.setLayoutParams(new LayoutParams(
                 LayoutParams.FILL_PARENT,
                 LayoutParams.WRAP_CONTENT)); 

         // Create a TextView to house the name of the province
         name[i]= new TextView(this);
         name[i].setId(200+i);
         name[i].setText(dataList.getName().get(i));
         name[i].setTextColor(Color.WHITE);
         name[i].setLayoutParams(new LayoutParams(
                 LayoutParams.FILL_PARENT,
                 LayoutParams.WRAP_CONTENT));
         tr.addView(name[i]);

         class[i] = new TextView(this);
         class[i].setId(i);
         class[i].setText(dataList.getClass().get(i));
         class[i].setTextColor(Color.WHITE);
         class[i].setLayoutParams(new LayoutParams(
                 LayoutParams.FILL_PARENT,
                 LayoutParams.WRAP_CONTENT));
         tr.addView(class[i]);


        t1.addView(tr, new TableLayout.LayoutParams(
                 LayoutParams.FILL_PARENT,
                 LayoutParams.WRAP_CONTENT));
     }
}
  • 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-05-20T17:58:30+00:00Added an answer on May 20, 2026 at 5:58 pm

    Invoke ViewGroup method:

    public int indexOfChild (View child)
    

    on TableLayout, where child is TableRow. TableRow should be accesible through

    public final ViewParent getParent ()
    

    of View inside TableRow.

    TableRow tableRow = (TableRow)mTextView.getParent();    
    
    int index = -1;
    
    if(parent != null){
        index = mTable.indexOfChild(tableRow);
    }
    
    if(index < 0){
        throw new IllegalStateException("TextView not found");
    }
    

    Hope that help, but I haven’t tested it.

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

Sidebar

Related Questions

I have used a custom array adapter to populate my list view.The problem i
I have list view with custom array adapter. I want to get items click
When my list view using a BaseAdapter goes off the screen, each row no
I am using a list view in Android 1.5 to show a list of
I am trying to create a list view which as TextView that can display
I have a list view with text and button in each row, list view
I have a list view in which I can insert items(the items are inserted
i am using a list view in which i want to directly shift to
I have a list view which contains a button in each row of the
I have a list view adapter that uses different types of view rows. Most

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.