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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:14:44+00:00 2026-06-05T09:14:44+00:00

In my application , I am dynamically generating a linearlayout that contains an edittext

  • 0

In my application , I am dynamically generating a linearlayout that contains an edittext and some Buttons .

I want that when the user presser the ‘enter’ on the keyboard of device the keyboard should hide

I tried it by setting the input type of the edittext , But by this when the user presses “enter” it moves onto another edittext .

How can i do that??

package com.integrated.mpr;

import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;


public class Page1 extends Activity implements OnClickListener{


    static String partname;
    int pos = StaticError.n;
    int ns= StaticError.ns;
    String s = StaticError.s;
    int[][] id = new int[pos][6];
    int submit ;

    double timedataa[] = {0,0,0,0,0};
    double timedatab[] = {0,0,0,0,0};
    double timedatac[] = {0,0,0,0,0};
    double timedata[] = {0,0,0,0,0};

    double rawdataa[] = new double[22050];
    double rawdatab[] = new double[22050];
    double rawdatac[] = new double[22050];
    double rawdata[] = new double[22050];


    FeatureExtract fe = new FeatureExtract();
    WavToDat wtd = new WavToDat();
    int i;


    int a=0;
    int b=0;
    int c=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);


        int p =0;
        Log.d("value of ", ""+pos);
        //Creating Different ids for the elements for different layouts
        for(int i =0;i<pos;i++){
            for(int j =0;j<6;j++){
                id[i][j] = p;
                p++;
            }
        }

        ScrollView sv = new ScrollView(this);



        LinearLayout ll = new LinearLayout(this);
        ll.setOrientation(LinearLayout.VERTICAL);
        int resid = getResources().getIdentifier("background", "drawable", getPackageName());
        ll.setBackgroundResource(resid);

        Button ins = new Button(this);
        ins.setText("Instructions");
        ins.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
        ins.setGravity(Gravity.RIGHT);
        ins.setId(5000);
        ins.setOnClickListener(new OnClickListener() 
        {
            public void onClick(View v) 
            {
                // TODO Auto-generated method stub
                Context mContext = Page1.this;
                Dialog dialog = new Dialog(mContext);
                dialog.setTitle("Instructions");
                dialog.setContentView(R.layout.instructiondialog);
                dialog.show();
            }
        });

        ins.setTextColor(Color.BLUE);
        ins.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
        ins.setTypeface(Typeface.SERIF);
        ll.addView(ins);


        for(i=0;i<pos;i++){



            LinearLayout llay = new LinearLayout(this);
            llay.setOrientation(LinearLayout.VERTICAL);
            llay.setId(id[i][5]);

            //EDIT TEXT
            EditText et = new EditText(this);
            et.setId(id[i][0]);
            et.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
            et.setTypeface(Typeface.SERIF);



            LinearLayout lhor = new LinearLayout(this);
            lhor.setOrientation(LinearLayout.HORIZONTAL);
            lhor.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
            lhor.setWeightSum(90);


            Button starta = new Button(this);
            starta.setText("Record 1");
            starta.setId(id[i][1]);
            starta.setOnClickListener(this);


            Button startb = new Button(this);
            startb.setText("Record 2");
            startb.setId(id[i][2]);

            startb.setOnClickListener(this);


            Button startc = new Button(this);
            startc.setText("Record 3");
            startc.setId(id[i][3]);

            startc.setOnClickListener(this);

            lhor.addView(starta);
            lhor.addView(startb);
            lhor.addView(startc);

            Button stop = new Button(this);
            stop.setText("Submit");
            stop.setId(id[i][4]);

            stop.setOnClickListener(this);


            TextView tv1 = new TextView(this);
            tv1.setVisibility(llay.INVISIBLE);

            llay.addView(tv);
            llay.addView(et);
            llay.addView(lhor);
            llay.addView(stop);
            llay.addView(tv1);
            ll.addView(llay);

        }



        sv.addView(ll);
        this.setContentView(sv);


    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub





        }





}
  • 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-05T09:14:45+00:00Added an answer on June 5, 2026 at 9:14 am

    Try the following:

    final EditText et = new EditText(this);
            et.setId(id[i][0]);
            et.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
            et.setTypeface(Typeface.SERIF);
    
    et.setOnKeyListener(new View.OnKeyListener()
            {
    
                @Override
                public boolean onKey(View editView, int keyCode, KeyEvent event)
                {
                    Context mContext = Page1.this;
                    if( keyCode == KeyEvent.KEYCODE_ENTER ){
                        et.clearFocus();
                        InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
                        imm.hideSoftInputFromWindow(et.getWindowToken(),0);
                        return true;
                    }
                    return false;
                }
            })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am having a application where i am generating the uibuttons dynamically want to
I am developing a web application such a way that my codes dynamically generating
I have a web application that dynamically loads assemblies based on database configuration entries
I have a .Net application that dynamically creates a small HTML page and pops
I have a Winforms application that dynamically instantiates external form objects for use in
I am developing a single web application that will dynamically change its content depending
Our application has many controls that are created dynamically. For example, a navigation pane
I am using master page in which menu is generating dynamically according to user
I'm having an issue with my android application. I want to dynamically create 4
I have a charting application that dynamically generates SQL Server queries to compute values

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.