0

I want to access the child of a widget created by a LayoutInflater in order to change the text displayed by a TextView inside it. How could I do this? I've made a diagram to explain.

LinearLayout
--->LayoutInflater

    ---->LinearLayout
         ---->LinearLayout
              ---->TextView
              ---->TextView
    ---->LinearLayout
         ---->LinearLayout
              ---->TextView
              ---->TextView
    ---->LinearLayout
         ---->LinearLayout
              ---->TextView
              ---->TextView
etc

I want to be able to access each individual TextView and change it's attributes.

Tim
  • 834
  • 2
  • 12
  • 31

1 Answers1

1

You can access the TextViews and change it's attributes through the View returned by the inflater.

I assume you have something like this:

View view = inflater.inflate(R.layout.my_layout, null);

Then you can access the resources like this:

TextView text = (TextView)view.findViewById(R.id.textView1);
text.setText("Hello");
Andy Res
  • 15,963
  • 5
  • 60
  • 96