Hello,

I'm a newbie, so please excuse if this is a basic question:

Is there a way to get all the children views of a layout, from the
Java code so that I can loop through them and set an attribute?
Specifically, I'd like to set the "layout_width" based on the screen
size.  Since this "layout_width" would be the same for all the views,
I'd prefer to loop through instead of calling each individual View
separately by their id.

I've searched, but I couldn't find anything, and I'm wondering if I'm
off the track.
I'd appreciate any help.

Thanks!


The following is my main.xml:

<?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="wrap_content">

<LinearLayout
      android:id="@+id/myRow1"
      android:orientation="horizontal"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_weight="1">
      <TextView
          android:text="1"
          android:layout_width="wrap_content"
          android:layout_height="50dip"
          android:layout_weight="1"/>

      <TextView
          android:text="2"
          android:layout_width="wrap_content"
          android:layout_height="50dip"
          android:layout_weight="1"/>

      <TextView
          android:text="3"
          android:layout_width="wrap_content"
          android:layout_height="50dip"
          android:layout_weight="1"/>

      <TextView
          android:text="4"
          android:layout_width="wrap_content"
          android:layout_height="50dip"
          android:layout_weight="1"/>

      <TextView
          android:text="5"
          android:layout_width="wrap_content"
          android:layout_height="50dip"
          android:layout_weight="1"/>

      <TextView
          android:text="6"
          android:layout_width="wrap_content"
          android:layout_height="50dip"
          android:layout_weight="1"/>

  </LinearLayout>
</LinearLayout>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to