I have a code like this:
protected void onActivityResult(int requestCode, int resultCode, Intent returnIntent)
{
super.onActivityResult(requestCode,resultCode, returnIntent);
RelativeLayout layout2=(RelativeLayout)findViewById(R.id.RltLayout);
Bundle extrasBundle = returnIntent.getExtras();
String temp = extrasBundle.getString("FollowList");
final int restSize;
if(temp != null) {
for(int i=0;i<count;i++)
{
Button Bt=(Button) layout2.getChildAt(i) ;
CharSequence St= Bt.getText();
orders[i]=IndexOfLabel((String) St);
}
List<String> restList = Arrays.asList(temp.split(","));
}
}
for the firs time, layout.getchildat() works perfect. when I change the layout and views, I get the previous results and the function does not work. what is the problem and how I can solve it.
I solved the problem. actually it was my fault because before rearange the views I did not remove the old views. by adding the following code and remove all views and reconstruction the layout, I solved my problem.
if(layout2.getChildCount() > 0)
layout2.removeAllViews();