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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:54:50+00:00 2026-06-10T14:54:50+00:00

WHAT I HAVE I created a table layout where the rows are dynamically added.

  • 0

WHAT I HAVE

I created a table layout where the rows are dynamically added.
I have 2 editTexts as columns.

WHAT I WANT

  • If a table row’s second editText is focused and enter is pressed, then:
    1. If a table row exists below, focus should be set to it’s edittext.
    2. If NO table row exists below, table row should be added and then focus set.

I think I need something like:

If(tablerow exists below){
  //do the focusing
}
else{
  //add new row
  //do the focusing
}

I used a function addView to add the rows :

public void addView(Context context) {

    int dpConv = (int) getResources().getDisplayMetrics().density;

    i = i + 1;
    try {

        txt_itemName[i] = new EditText(context);
        txt_itemName[i].setText("itName");
        txt_itemName[i].requestFocus();


        txt_qty[i] = new EditText(context);
        txt_qty[i].setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
        txt_qty[i].setImeOptions(EditorInfo.IME_ACTION_NEXT);
        txt_qty[i].setOnEditorActionListener(new OnEditorActionListener() {

                public boolean onEditorAction(TextView v, int actionId, KeyEvent event)                                            

        {

                        if(actionId == EditorInfo.IME_ACTION_NEXT){

                                txt_qty[i].clearFocus();

                                //Need to check conditions here
                        }

        return false;
        }
        });

        tb_row[i] = new TableRow(context);
        tb_row[i].addView(txt_itemName[i]);
        tb_row[i].addView(txt_qty[i]);

        tb_lyt.addView(tb_row[i]);
  • 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-10T14:54:51+00:00Added an answer on June 10, 2026 at 2:54 pm

    Ok. what about if you try this:

    if(actionId == EditorInfo.IME_ACTION_NEXT){
    
        txt_qty[i].clearFocus();
    
        //Need to check conditions here
        /* I'm assuming that:
              You have the value of i
              You add TableRows ONLY to your TableLayout
        */
        if(tb_lyt.getChildCount() > (i+1)) {
            //If a child exist below
            //Do your focus setting
        }
        else {
            //Add a new Row.
        }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a Table layout with a number of rows and each row
I have created a table layout in which my table row height is too
I have created a table in Visual Studio. That table has two columns. First
I have created a table with the following columns: ObservationId, FirstCreatedDate, description, ... ...
I have created a table view with navigation controller. I want to link table
We have created a table dynamically in our main activity, however we need to
I want to create a table layout with custom table rows. Those rows should
I have created a Table Layout named table and I am trying to add
I have the following problem spanning dynamically added rows to a TableLayout inside a
I have created table and inserted values as below. create table mytable (id INT,

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.