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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:35:03+00:00 2026-06-15T13:35:03+00:00

I am trying to delete table row created dinammically, but i can’t get the

  • 0

I am trying to delete table row created dinammically, but i can’t get the right table row id, all my table rows have the same id, more that i create them, my counter sets higher id and all rows get it… I’ll appreciate any help, i’m stuck on this for a few days. My method is big, but only beginning is important i think.

 public void getRow(String klik, int brojkica)
{
    //db=openOrCreateDatabase(DATABASE_NAME, Context.MODE_PRIVATE, null);
    db = INF.getReadableDatabase();
    int count = 0;
    Cursor cursor3 = db.rawQuery("select id,Artikl, CIJENA from Artikli where");
    System.out.println(counterko);
    counterko++;
    tr = new TableRow(this);
    tr.setClickable(true);
    tr.setBackgroundColor(Color.GRAY);

    tr.setId(500 + counterko);

    cursor3.moveToFirst();
    final TextView sifracolumn = new TextView(this);
    sifracolumn.setId(1000 + counterko);

    sifracolumn.setPadding(5, 5, 5, 5);
    sifracolumn.setText(String.valueOf(cursor3.getInt(0)));
    sifracolumn.setGravity(Gravity.CENTER | Gravity.BOTTOM);
    sifracolumn.setTextColor(Color.BLACK);
    tr.addView(sifracolumn);
    allIDs.add(sifracolumn);//////////////////////////////////////

    final TextView artiklcolumn = new TextView(this);
    artiklcolumn.setPadding(5, 5, 5, 5);
    artiklcolumn.setId(2000 + counterko);
    artiklcolumn.setClickable(true);
    artiklcolumn.setWidth(400);
    artiklcolumn.setText(cursor3.getString(1));
    artiklcolumn.setGravity(Gravity.CENTER | Gravity.BOTTOM);
    artiklcolumn.setTextColor(Color.BLACK);
    tr.addView(artiklcolumn);
    artiklcolumn.setOnClickListener(new View.OnClickListener()
    {

        public void onClick(View v)
        {
            // TODO Auto-generated method stub
            //alert(tr.getId());
            alert(artiklcolumn.getId());
        }
    });
    final TextView cijenacolumn = new TextView(this);
    cijenacolumn.setId(3000 + count);
    cijenacolumn.setText(cursor3.getString(2));
    cijenacolumn.setWidth(120);
    cijenacolumn.setGravity(Gravity.CENTER | Gravity.BOTTOM);
    cijenacolumn.setTextColor(Color.BLACK);

    tr.addView(cijenacolumn);

    final EditText kolicinacolumn = new EditText(this);
    kolicinacolumn.setId(4000 + counterko);
    kolicinacolumn.setText("1");
    kolicinacolumn.setGravity(Gravity.CENTER | Gravity.BOTTOM);
    kolicinacolumn.setTextColor(Color.BLACK);

    allEds.add(kolicinacolumn);
    tr.addView(kolicinacolumn);

    final TextView iznoscolumn = new TextView(this);
    iznoscolumn.setId(5000 + counterko);
    iznoscolumn.setWidth(120);
    iznoscolumn.setText("");
    iznoscolumn.setTextColor(Color.BLACK);
    iznoscolumn.setGravity(Gravity.CENTER | Gravity.BOTTOM);
    tr.addView(iznoscolumn);
    allTexts.add(iznoscolumn);

    if (kolicinacolumn.getText().toString() == "1")
    {

        System.out.println("kme");
        iznoscolumn.setText(cijenacolumn.getText().toString());
    }
    zaplatiti();
    tl = (TableLayout) findViewById(R.id.tableLayout1);
    tl.addView(tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    count++;
    kolicinacolumn.addTextChangedListener(new TextWatcher()
    {


        public void onTextChanged(CharSequence s, int start, int before, int count)
        {
            String kol = kolicinacolumn.getText().toString();
            if (TextUtils.isEmpty(kol))
            {
                try
                {
                    System.out.print("Stop it");
                } catch (NumberFormatException e)
                {
                    System.out.println("This is not a number");
                    System.out.println(e.getMessage());
                }
            } else
            {
                Float racunam = Float.valueOf(kol);
                Float racunam2 = Float.valueOf(cijenacolumn.getText().toString());
                Float reza = racunam * racunam2;
                iznoscolumn.setText(String.valueOf(reza));
            }
            zaplatiti();
        }

        public void afterTextChanged(Editable s)
        {
            // TODO Auto-generated method stub      
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after)
        {
            //TODO 
        }
    });
}
  • 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-15T13:35:04+00:00Added an answer on June 15, 2026 at 1:35 pm

    ok, i solved my problem..first problem was

    tr = new TableRow(this); 
    

    i couldn’t assign id to my table row because id didn’t instantiate it in my method, so first thing to do was

    final TableRow tr = new TableRow(this);
    

    then i put onclicklistener on column which i wanted to be responsive and put this in..

     artiklcolumn.setOnClickListener(new View.OnClickListener(){
    public void onClick(View v) {
    TableRow km= (TableRow)findViewById(tr.getId());                
    alert(km);
    
    }
    

    in which i get my object, send it to alert dialog and from there to method do delete it.

     public void delete(TableRow tr2){
    
     tl.removeView(tr2);       
    
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to delete all rows in a table using Castle ActiveRecord. Normally, I
I'm trying to delete a row from my table view and so far have
I have a table that I am trying to dynamically delete rows from. Each
I am trying to delete MySQL table rows from a Web page using Perl.
I am trying to delete a project from the projects table and all the
I am trying to make a schedule table that would delete certain rows according
I have a problem when trying to delete rows from my UITableView: The UITableView
I have two tables, products(product_id) and sex(product_id,sex_id). I am trying to DELETE rows from
I get this error when trying to delete a row on a view ORA-01732:
I am trying to insert rows into an html table with javascript. I have

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.