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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:56:50+00:00 2026-05-29T06:56:50+00:00

I’m getting data from mssql dynamically in my table. I want to get values

  • 0

I’m getting data from mssql dynamically in my table. I want to get values in selected row as String. For example i want to get “99” , “Yonca” , “Lodi” values for this screen. How can i do this? Here is my creating table code :

public void addData()
{
    for(int i = 0 ; i < protokolNo.length ; i++)
    {
        /**
         * Creating table row here
         */
        tr = new TableRow(this);
        tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));

        tVProtokolNo = new TextView (this);
        tVProtokolNo.setText(protokolNo[i]);
        tVProtokolNo.setTextColor(Color.RED);
        tVProtokolNo.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
        tVProtokolNo.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
        tVProtokolNo.setPadding(5, 5, 5, 5);
        tr.addView(tVProtokolNo);

        TextView tVAdi = new TextView(this);
        tVAdi.setText(adi[i]);
        tVAdi.setTextColor(Color.RED);
        tVAdi.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
        tVAdi.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
        tVAdi.setPadding(5, 5, 5, 5);
        tr.addView(tVAdi);

        TextView tVSoyadi = new TextView(this);
        tVSoyadi.setText(soyadi[i]);
        tVSoyadi.setTextColor(Color.RED);
        tVSoyadi.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
        tVSoyadi.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
        tVSoyadi.setPadding(5, 5, 5, 5);
        tr.addView(tVSoyadi);

        tl.addView(tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

        /**
         *  Colouring selected row
         */

        tr.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    v.setBackgroundColor(Color.DKGRAY);
                    v.showContextMenu();


                }
            });
            registerForContextMenu(tr);
    }
}
  • 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-29T06:56:51+00:00Added an answer on May 29, 2026 at 6:56 am

    This is dirty but working.
    Create a global private variable in your Activity class
    called TableRow tr1=null;
    then you can use the following code within your addData() method
    before registerForContextMenu(tr); call:

       tr.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            view.setBackgroundColor(Color.DKGRAY);
        }
        });
    
        tr.setOnLongClickListener(new View.OnLongClickListener() {
                public boolean onLongClick(View v) {
                    tr1=(TableRow)v; //assign selected TableRow gobally
                    openContextMenu(v);
                    return true;
                }
            });
    

    Then use the following in the same Activity to make it work with the context menus as far as I got it from your code:

      @Override
         public void onCreateContextMenu(ContextMenu menu, View v,ContextMenu.ContextMenuInfo menuInfo) {
         super.onCreateContextMenu(menu, v, menuInfo);
             menu.add(0, v.getId(), 0, "Do YourStuff");
    
         }
        @Override
           public boolean onContextItemSelected(MenuItem item) {
            int ccount= (tr1).getChildCount();
                              String[] str =new String[ccount];
                              for(int i=0;i<ccount;i++)
                              {
                                  TextView tv =   (TextView)(((TableRow)tr1)).getChildAt(i);
                                  str[i]=tv.getText().toString(); //set selected text data into the String array
                              }
                              Toast.makeText(ListActivity2.this,Arrays.toString(str), 2).show();
            return true;
        }
    

    so basically tr1 variable will host your selected TableRow.

    But do as everyone says use the ListView for the tasks like this one and just use RelativeLayouts for the rows or anything.

    hope it clarifies it abit.

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

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
i got an object with contents of html markup in it, for example: string
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And

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.