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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:45:47+00:00 2026-05-25T12:45:47+00:00

I call on a few EditTexts via instanceOf because I don’t necessarily know the

  • 0

I call on a few EditTexts via “instanceOf” because I don’t necessarily know the exact names / ids of them. When I do this to get the text, it works just fine. But when I try to setText() based on the local instanceOf EditText, it won’t display the string I am passing it. Oddly enough, when I setText and then Log the getText, it logs it correctly — it just won’t physically display it.

I also tested setting the visibility to View.INVISIBLE or View.GONE just to see if i can interact with it at all, and it doesn’t do anything.

Here is the code snippet that sets the text then logs it:

    LinearLayout mLayout = (LinearLayout) main_fields_holder.getChildAt(0);
         LinearLayout mLayout2 = (LinearLayout) mLayout.getChildAt(0);
         LinearLayout mLayout3 = (LinearLayout) mLayout2.getChildAt(1);
for(int i = 0; i < mLayout3.getChildCount(); i++){
                    View v = (View) mLayout3.getChildAt(i);
                    if (v instanceof EditText){
                        EditText e = (EditText) v;
                        e.setText("HELLO");

                        Log.v("USER TEXT", "Text is: " + e.getText().toString() + "!");

                        ;

                    }
} 

I should also mention that I do the same instanceOf method with button text and it won’t display my setText either.

Is there some reason that a local instance of an editText (or button) cannot be manipulated?

By the way, the line Log.v(“USER TEXT”, “Text is: ” + e.getText().toString() + “!”); DOES give me “HELLO!”. I’m not even sure what that means for my problem.

The main layout file is:

<?xml version="1.0" encoding="utf-8"?>
   <LinearLayout    
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:background="#fff"
        xmlns:android1="http://schemas.android.com/apk/res/android">


    <ScrollView android:id="@+id/scrollView1" android:layout_width="fill_parent" android:layout_height="fill_parent">
      <LinearLayout 
        android:orientation="vertical" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" android1:focusable="false">

       <LinearLayout android:id="@+id/item_edit_linear" 
        android:layout_height="wrap_content"
        android:background="@drawable/backrepeat"
        android:layout_width="fill_parent"
        >
            <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/add_item_text" android:text="Add New Item" android:textStyle="bold" android:paddingLeft="15dip" android1:paddingTop="8dip" android1:textSize="12pt" android1:textColor="@color/blue"></TextView>
        </LinearLayout>
       <LinearLayout android1:layout_height="wrap_content" android1:layout_width="fill_parent" android1:orientation="vertical" android1:paddingLeft="15dip" android1:background="@drawable/borderlines" android1:paddingBottom="15dip" android1:paddingTop="10dip" android1:id="@+id/spinner_holder_layout">
           <TextView android1:layout_height="wrap_content" android1:layout_width="wrap_content" android1:paddingTop="5dip" android1:text="Item Name:" android1:textColor="@color/gray" android1:paddingBottom="5dip"></TextView>
           <EditText android1:layout_height="wrap_content" android1:layout_width="290dip" android1:id="@+id/edit_item_title">
               <requestFocus></requestFocus>
           </EditText>
           <TextView android1:layout_height="wrap_content" android1:layout_width="wrap_content" android1:paddingTop="5dip" android1:id="@+id/textView9" android1:text="Select Category:" android1:textColor="@color/gray" android1:paddingBottom="5dip"></TextView>
           <Spinner android1:layout_height="wrap_content" android1:layout_width="wrap_content" android1:prompt="@string/edit_item_category_spinner_text" android1:id="@+id/edit_item_category_spinner" android1:entries="@array/categoryList" android1:paddingBottom="10dip"></Spinner>
           <LinearLayout android1:layout_height="wrap_content" android1:layout_width="fill_parent" android1:orientation="vertical" android1:id="@+id/item_spinner_layout" android1:visibility="gone">
               <TextView android1:layout_height="wrap_content" android1:layout_width="wrap_content" android1:paddingTop="5dip" android1:id="@+id/textView10" android1:text="Select Item" android1:textColor="@color/gray" android1:paddingBottom="5dip"></TextView>
               <Spinner android1:layout_height="wrap_content" android1:layout_width="wrap_content" android1:prompt="@string/edit_item_item_spinner_text" android1:paddingBottom="10dip" android1:id="@+id/edit_item_spinner"></Spinner>
           </LinearLayout>
       </LinearLayout>
       <LinearLayout android1:layout_height="wrap_content" android1:layout_width="fill_parent" android1:orientation="vertical" android1:id="@+id/editItemFields">

       </LinearLayout>
       <LinearLayout android1:layout_marginLeft="15dip" android1:layout_width="fill_parent" android1:layout_height="wrap_content" android1:id="@+id/date_time_container" android1:visibility="gone">
           <LinearLayout android1:layout_width="wrap_content" android1:layout_height="fill_parent" android1:id="@+id/linearLayout7" android1:orientation="vertical">
               <TextView android1:layout_width="fill_parent" android1:id="@+id/dep_date_text" android1:textColor="@color/gray" android1:layout_marginBottom="10dip" android1:text="Departure Date:" android1:gravity="right|center" android1:layout_height="36dip"></TextView>
               <TextView android1:layout_width="fill_parent" android1:id="@+id/dep_time_text" android1:textColor="@color/gray" android1:layout_marginBottom="9dip" android1:text="Depature Time:" android1:gravity="right|center" android1:layout_height="36dip"></TextView>
               <TextView android1:layout_width="fill_parent" android1:id="@+id/arr_date_text" android1:textColor="@color/gray" android1:layout_marginBottom="9dip" android1:text="Arrival Date:" android1:gravity="right|center" android1:layout_height="36dip"></TextView>
               <TextView android1:layout_width="fill_parent" android1:id="@+id/arr_time_text" android1:textColor="@color/gray" android1:layout_marginBottom="9dip" android1:text="Arrival Time:" android1:gravity="right|center" android1:layout_height="36dip"></TextView>
           </LinearLayout>
           <LinearLayout android1:layout_marginLeft="5dip" android1:layout_width="wrap_content" android1:layout_height="fill_parent" android1:id="@+id/linearLayout8" android1:orientation="vertical">
               <Button android1:layout_width="wrap_content" android1:layout_height="45dip" android1:id="@+id/departure_date" android1:minWidth="125dip" android1:text="Button"></Button>
               <Button android1:layout_width="wrap_content" android1:layout_height="45dip" android1:id="@+id/departure_time" android1:minWidth="125dip" android1:text="Button"></Button>
               <Button android1:layout_width="wrap_content" android1:layout_height="45dip" android1:id="@+id/arrival_date" android1:minWidth="125dip" android1:text="Button"></Button>
               <Button android1:layout_width="wrap_content" android1:layout_height="45dip" android1:id="@+id/arrival_time" android1:minWidth="125dip" android1:text="Button"></Button>
           </LinearLayout>
       </LinearLayout>

        <LinearLayout android:layout_width="fill_parent" android:id="@+id/editItemLinearLayout" 
        android:layout_height="fill_parent" android:orientation="vertical" android1:paddingLeft="15dip" android1:visibility="gone">
        <TextView android:text="Cost" android:id="@+id/textView1" 
            android:layout_width="wrap_content" android:layout_height="wrap_content">
        </TextView>
        <EditText android:layout_height="wrap_content" 
            android:layout_width="fill_parent" android:id="@+id/edit_item_cost">
        </EditText>
        <TextView android:text="Contact Phone" android:id="@+id/textView2" 
            android:layout_width="wrap_content" android:layout_height="wrap_content">
        </TextView>
        <EditText android:layout_height="wrap_content" 
            android:layout_width="fill_parent" android:id="@+id/edit_item_phone">
        </EditText>
        <TextView android:text="Carrier" android:id="@+id/textView3" 
            android:layout_width="wrap_content" android:layout_height="wrap_content">
        </TextView>
        <EditText android:layout_height="wrap_content" 
            android:layout_width="fill_parent" android:id="@+id/edit_item_carrier">
        </EditText>
        <TextView android:text="Names" android:id="@+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
        <EditText android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/edit_item_names">
        </EditText>
        <TextView android:text="Departure Location" android:id="@+id/textView5" 
            android:layout_width="wrap_content" android:layout_height="wrap_content">
        </TextView>
        <EditText  android:layout_height="wrap_content" 
            android:layout_width="fill_parent" android:id="@+id/edit_item_departure_location">
        </EditText>
        <TextView android:text="Arrival Location" android:id="@+id/textView6" 
            android:layout_width="wrap_content" android:layout_height="wrap_content">
        </TextView>
        <EditText android:layout_height="wrap_content" 
            android:layout_width="fill_parent" android:id="@+id/edit_item_arrival_location">
        </EditText>
        <TextView android:id="@+id/textView7" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Date"></TextView>
        <Button android:text="Button" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/edit_item_reminder_date"></Button>
        <TextView android:id="@+id/textView8" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Time"></TextView>
        <Button android:text="Button" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/edit_item_reminder_time"></Button>
        </LinearLayout>
        <RelativeLayout android1:layout_width="fill_parent" android1:layout_marginTop="50dip" 
        android1:id="@+id/relativeLayout1" android1:layout_height="fill_parent">
            <Button android1:id="@+id/edit_item_confirm" android1:layout_width="wrap_content" android1:layout_height="wrap_content" android1:background="@drawable/savebutton" android1:layout_alignParentBottom="true"></Button>
            <Button android1:width="159dip" android1:background="@drawable/cancelbutton" android1:layout_width="wrap_content" android1:id="@+id/item_creation_cancel" android1:layout_height="wrap_content" android1:layout_alignParentRight="true" android1:layout_alignParentBottom="true"></Button>
        </RelativeLayout>

        </LinearLayout>

    </ScrollView>

    </LinearLayout>

Through code, I inflate the editItemFields Layout with the following:

<LinearLayout android1:paddingLeft="15dip" android1:layout_width="fill_parent" 
android1:background="@color/white" android1:id="@+id/flight_edit_container" 
android1:orientation="vertical" android1:layout_height="fill_parent" 
xmlns:android1="http://schemas.android.com/apk/res/android" android1:paddingTop="10dip">
    <LinearLayout android1:layout_height="wrap_content" android1:layout_width="fill_parent" android1:id="@+id/linearLayout6">
        <LinearLayout android1:layout_height="fill_parent" android1:layout_width="wrap_content" android1:id="@+id/linearLayout7" android1:orientation="vertical">
            <TextView android1:id="@+id/TextView02" android1:textColor="@color/gray" android1:layout_width="fill_parent" android1:gravity="right|center" android1:layout_height="36dip" android1:layout_marginBottom="10dip" android1:text="Airline:"></TextView>
            <TextView android1:text="Flight #:" android1:id="@+id/TextView05" android1:textColor="@color/gray" android1:layout_width="fill_parent" android1:gravity="right|center" android1:layout_height="36dip" android1:layout_marginBottom="10dip"></TextView>
            <TextView android1:text="Gate:" android1:id="@+id/TextView04" android1:textColor="@color/gray" android1:gravity="right|center" android1:layout_width="100dip" android1:layout_height="36dip" android1:layout_marginBottom="10dip"></TextView>
            <TextView android1:id="@+id/TextView09" android1:textColor="@color/gray" android1:layout_width="fill_parent" android1:gravity="right|center" android1:text="Departure Location:" android1:layout_height="36dip" android1:layout_marginBottom="10dip"></TextView>
            <TextView android1:text="Departure Airport:" android1:id="@+id/TextView14" android1:textColor="@color/gray" android1:layout_width="fill_parent" android1:gravity="right|center" android1:layout_height="36dip" android1:layout_marginBottom="10dip"></TextView>
            <TextView android1:text="Confirmation #:" android1:id="@+id/TextView12" android1:textColor="@color/gray" android1:layout_width="fill_parent" android1:gravity="right|center" android1:layout_height="36dip" android1:layout_marginBottom="9dip"></TextView>
            <TextView android1:gravity="right|center" android1:text="Destination:" android1:id="@+id/TextView08" android1:textColor="@color/gray" android1:layout_width="fill_parent" android1:layout_height="36dip" android1:layout_marginBottom="9dip"></TextView>
            <TextView android1:text="Arrival Airport:" android1:id="@+id/TextView15" android1:textColor="@color/gray" android1:layout_width="fill_parent" android1:gravity="right|center" android1:layout_height="36dip" android1:layout_marginBottom="9dip"></TextView>
            <TextView android1:text="Cost:" android1:id="@+id/TextView09" android1:textColor="@color/gray" android1:layout_width="fill_parent" android1:gravity="right|center" android1:layout_height="36dip" android1:layout_marginBottom="9dip"></TextView>
            <TextView android1:text="Class:" android1:id="@+id/TextView08" android1:textColor="@color/gray" android1:layout_width="fill_parent" android1:gravity="right|center" android1:layout_height="36dip" android1:layout_marginBottom="9dip"></TextView>
            <TextView android1:text="Seat:" android1:id="@+id/TextView11" android1:textColor="@color/gray" android1:layout_width="fill_parent" android1:gravity="right|center" android1:layout_height="36dip" android1:layout_marginBottom="9dip"></TextView>
            <TextView android1:text="Travelers:" android1:id="@+id/TextView12" android1:textColor="@color/gray" android1:layout_width="fill_parent" android1:gravity="right|center" android1:layout_height="36dip" android1:layout_marginBottom="9dip"></TextView>
            <TextView android1:text="Memo:" android1:id="@+id/TextView13" android1:textColor="@color/gray" android1:layout_width="fill_parent" android1:gravity="right|center" android1:layout_height="36dip" android1:layout_marginBottom="9dip"></TextView>
        </LinearLayout>
        <LinearLayout android1:layout_height="fill_parent" android1:layout_width="wrap_content" android1:id="@+id/linearLayout8" android1:orientation="vertical" android1:layout_marginLeft="5dip">
            <EditText android1:layout_width="190dip" android1:layout_height="45dip" android1:id="@+id/flight_airline"></EditText>
            <EditText android1:layout_width="190dip" android1:id="@+id/flight_number" android1:layout_height="45dip"></EditText>
            <EditText android1:layout_width="190dip" android1:id="@+id/flight_gate" android1:layout_height="45dip"></EditText>
            <EditText android1:layout_width="190dip" android1:id="@+id/flight_deplocation" android1:layout_height="45dip"></EditText>
            <EditText android1:layout_width="190dip" android1:id="@+id/flight_depairport" android1:layout_height="45dip"></EditText>
            <EditText android1:layout_width="190dip" android1:id="@+id/flight_confirmation" android1:layout_height="45dip"></EditText>
            <EditText android1:layout_height="45dip" android1:layout_width="190dip" android1:id="@+id/flight_destination"></EditText>
            <EditText android1:layout_height="45dip" android1:layout_width="190dip" android1:id="@+id/flight_arrairport">
            </EditText>
            <EditText android1:layout_width="190dip" android1:layout_height="45dip" android1:id="@+id/flight_cost"></EditText>
            <EditText android1:layout_width="190dip" android1:layout_height="45dip" android1:id="@+id/flight_class"></EditText>
            <EditText android1:layout_width="190dip" android1:layout_height="45dip" android1:id="@+id/flight_seat"></EditText>
            <Button android1:text="Button" android1:minWidth="125dip" android1:id="@+id/flight_travelers" android1:layout_width="wrap_content" android1:layout_height="45dip"></Button>
            <EditText android1:layout_width="190dip" android1:id="@+id/flight_memo" android1:layout_height="45dip"></EditText>
        </LinearLayout>
    </LinearLayout>
           </LinearLayout>

I basically drill down into the layouts until i am at the linear layout that holds my editTexts.

Finally, here is the code snippets that inflate the layout:

main_fields_holder = (LinearLayout) findViewById(R.id.editItemFields);
view = LayoutInflater.from(getBaseContext()).inflate(R.layout.flight_fields,
                        null);
                 main_fields_holder.addView(view);

UPDATE:
Just to test, I added this line to see if i can hard reference it by id:

EditText a = ((EditText)findViewById(R.id.flight_airline));
            a.setText("HELLO");

And it STILL won’t show up. Could the fact that I inflate the layout that holds these items have anything to do with it? Basically when a spinner item is selected, a layout is inflated and I try to set the Text of the items in that layout, but to no avail. Btw, I can also still trace out the value of the EditText after setting it, but the bugger just won’t physically show up.

  • 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-25T12:45:47+00:00Added an answer on May 25, 2026 at 12:45 pm

    FYI I figured this out. For whatever reason, the app needed a moment to go through all of the functions that grab the information and set them, so I added a post handler:

    handler.postDelayed(new Runnable() {
    public void run() {
    populateFields(item);
    }
    }, 500);

    This 1/2 second wait allowed the information to be displayed properly. Thanks for everyone’s answers

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

Sidebar

Related Questions

I am sending quite a few values with my AJAX call, like this: var
I'm working with a few Perl packages, we'll call them Some::Parser and Some::Data .
How to call few model methods and send emails through my rake task?
I want to call a few static methods of a CPP class defined in
In few words, is it correct way to call keydown and keyup events, that
I've got a few methods that should call System.exit() on certain inputs. Unfortunately, testing
Html.Encode seems to simply call HttpUtility.HtmlEncode to replace a few html specific characters with
I'm trying to call the HtmlTidy library dll from C#. There's a few examples
I need to call a few webservices while constructing an MVC page, so I'm
I have a few camel routes that call an external web service, i need

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.