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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:34:11+00:00 2026-06-13T00:34:11+00:00

I am adding views to a layout at run time. thee views are like

  • 0

I am adding views to a layout at run time.
thee views are like so:

<LinearLayout android:id="@+id/ll1">
<LinearLayout android:id="@+id/ll2" >
    <ImageView android:id="@+id/iv1" />
    <TextView android:id="@+id/tv1"/>
    <ImageView android:id="@+id/iv2"/>
</LinearLayout>

(I took a lot out to make it simple)

Now in code I am adding any number of these to a layout. How then do I access the ImageViews and TextViews in each addition of this view?

Currently I have this complicated way going through each child and doing a

if (View instanceof ImageView)

if I were to call parentView.getChildAt(0) (where parent view is ll2) would this always return iv1? and at “1” would this always return tv1?

Then I have been storing these objects in a vector of itself, to call on them later.

Is there an easier way of doing this? Like when I first add the whole thing, is there a way I can just set the sources of the image views, and set the text of the textviews without having to go and find them this way?

  • 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-13T00:34:12+00:00Added an answer on June 13, 2026 at 12:34 am

    When you inflated your view,find it’s children and set a specific Tag for each child(use setTag() ).When you need to recognize,use getTag().You can find good idea in about usage of getTag and setTag in What is the main purpose of setTag() getTag() methods of View? and Android:setTag() and getTag() usage for changing the controls..

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

Sidebar

Related Questions

I am programatically adding custom views to a vertical LinearLayout, and I would like
Dynamically I am creating the linear layout and adding the views to linear layout
Using Android, here is part of a layout xml file: <LinearLayout android:layout_width=fill_parent android:layout_height=wrap_content android:orientation=vertical
I am new to Andriod and having difficult time adding controls (Views) on top
Hi i have a collection and two views. On my view1 i'm adding data
I tried adding a view with a white color like transparent so I set
I am following below code to create expandablistView in android withour xml layout.its working
I'm using a custom listview I found here: http://developer.android.com/resources/samples/ApiDemos/res/layout/linear_layout_9.html Seems to be valid in
I checked the solution here: Adding multiple views of the same type Its given
I need to organize complicated Activity with many Views inside. Also layout should depending

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.