If you do based on the conditions of the problem, you can do this:
for(int i = 0; i< data.linearLayout.getChildCount()-1; i++){ linearLayout.getChildAt(i).yourMethod(); }
Another option (again from the condition), as you suggested yourself, is to add all the View to ArrayList : myViews.add(inflatedView) and then also find it. This option is better if you have other non-task, View in linearLayout .
But the most correct, as you were told in the comments, is to use RecyclerView :
public class MyAdapter extends RecyclerView.Adapter<MyAdapter .ViewHolder> { private List<MyData> dataList; private Context ctx; //ΠΌΠΎΠΆΠ½ΠΎ ΡΠ±ΡΠ°ΡΡ Π΅ΡΠ»ΠΈ ΡΠ°Π±ΠΎΡΠ° Ρ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠΎΠΌ Π² Π°Π΄Π°ΠΏΡΠ΅ΡΠ΅ Π½Π΅ Π½ΡΠΆΠ½Π° public MyAdapter (Context ctx, List data) { this.ctx = ctx; dataList = data; } @Override public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.owner_item, viewGroup, false); return new MyAdapter.ViewHolder(v); } @Override public void onBindViewHolder(MyAdapter.ViewHolder viewHolder, int i) { //ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡΡ Π½ΡΠΆΠ½ΡΠ΅ Π΄Π΅ΠΉΡΡΠ²ΠΈΡ viewHolder.txt.setText(dataList.get(i).getName()); //Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ ΡΠ°ΠΊΠΈΠ΅ } @Override public int getItemCount() { return dataList.size(); } class ViewHolder extends RecyclerView.ViewHolder { private TextView txt; ViewHolder(View itemView) { super(itemView); txt = itemView.findViewById(R.id.myTV); txt.setOnClickListener(...); } } }
Fill RecyclerView like this:
recyclerView.setAdapter(new MyAdapter(this,myDataList)); recyclerView.setLayoutManager(new LinearLayoutManager(this));