selva_pollachi
selva_pollachi

Reputation: 4217

Get Views in a Table Row Android

for (int i = 0; i < listData.size(); i++) {         
 final TableRow tr = new TableRow(referenceActivity);
 tr.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
                                       LayoutParams.MATCH_PARENT));
 LayoutInflater inflater1 = (LayoutInflater) referenceActivity
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
 View rowData = inflater1.inflate(R.layout.categoryadapter, null);
 final ImageView lPic = (ImageView) rowData.findViewById(R.id.imageView1);
 final ImageView rPic = (ImageView) rowData.findViewById(R.id.imageView2);
 TextView category = (TextView) rowData.findViewById(R.id.textView_category);
 tr.addView(rowData);
 tv.addView(tr);            
}

If i click on a row, i want to change the images in ImageView.So I want to get the all three views ( two ImageView and one TextView ) in the row. How can i get the views in row?

Upvotes: 0

Views: 932

Answers (1)

Shayan Pourvatan
Shayan Pourvatan

Reputation: 11948

set one id to you TableRow while creating and every where you want get That just get that with following code.

TableRow tr = findViewById(yourId);

and for getting your imageView

ImageView iv =(ImageView ) tr.getChildAt(0); // 0 is imageView position in tableRow 
                                             // change that with your need

and if you add View directly you can try:

   ImageView iv = tr.findViewById(R.id.imageID);

Upvotes: 1

Related Questions