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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:32:30+00:00 2026-05-31T21:32:30+00:00

Thanks in advance. This is my sample code. Whenever i try to run it

  • 0

Thanks in advance.

This is my sample code. Whenever i try to run it and change the screen orientation both the edit text disappears and i have to restart the application.
please help me out

 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ed1=(EditText)findViewById(R.id.ed1);
    ed2=(EditText)findViewById(R.id.ed2);

    ed1.addTextChangedListener(new TextWatcher()                          
    {
        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        }

        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                int arg3) {
        }

        public void afterTextChanged(Editable arg0) {    
            ed2.setVisibility(View.INVISIBLE);
        }
    }); 

    ed2.addTextChangedListener(new TextWatcher()            
    {
        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {

        }    

        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                int arg3) {
        }

        public void afterTextChanged(Editable arg0) {   
            ed1.setVisibility(View.INVISIBLE);
        }
    });
}

This is my main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TableLayout
    android:id="@+id/table"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="25dip"
    android:stretchColumns="0,1" >

    <TableRow>

        <TextView
            android:id="@+id/text1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dip"
            android:text="Edit Text 1"
            android:textSize="15dip" />

        <EditText
            android:id="@+id/ed1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dip"
            android:layout_marginTop="20dip"
            android:maxLength="10"
            android:numeric="integer|decimal" />
    </TableRow>

    <TableRow>

        <TextView
            android:id="@+id/or_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dip"
            android:text="OR"
            android:textSize="20dip" />
    </TableRow>

    <TableRow>

        <TextView
            android:id="@+id/text2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dip"
            android:text="Edit Text2"
            android:textSize="15dip" />

        <EditText
            android:id="@+id/ed2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dip"
            android:layout_marginTop="20dip"
            android:maxLength="10"
            android:numeric="integer|decimal" />
    </TableRow>
</TableLayout>

  • 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-31T21:32:31+00:00Added an answer on May 31, 2026 at 9:32 pm

    Every time you rotate your device your activity restarts, that is why you do not see your EditTexts.

    Add this line of XML to your activity in Manifest file

    android:configChanges="orientation|keyboardHidden"
    

    Also check this out to know more about Runtime changes to your applications.

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

Sidebar

Related Questions

Sorry if this is too simple, but thanks in advance for helping. This is
Thanks in Advance for reading and answer this question. I got button in asp
First of all thanks in advance, this has been very frustrating and I'm hoping
This is a total newbie question, so thanks in advance. I'm trying to get
I'm programming a very simple socket server following this sample code . The server
This is the sample code for web services which am trying to implement .
Value Loss in my HTML editor and fileupload ctrl This is my sample code
Following this sample of slideshow asp.net ajax: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/SlideShow/SlideShow.aspx with this code snippet: <ajaxToolkit:SlideShowExtender ID=SlideShowExtender1
I try to get this code running. I am almost there but I got
Here is the sample code. How can I use this variable: Readme.txt as a

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.