MainView에 7개의 자식뷰가 있습니다. 그중 6개는 동적으로 생성한뒤 Tag값으로 제어를 하고 있고요
나머지 하나는 xml에 선언한뒤에 R.id를 받아서 Tag값을 선언한뒤 제어하고 있습니다.
처음에는 화면이 갱신될떄 6개의 자식뷰는 사라져야하지만 마지막 7번째 뷰는 삭제되지 않아야해서
루프로 돌려서 7번째 태그 가 아닌것들만 제거를 하려고 했더니 Main_View.getChildCount() 를 돌려서 태그 값을 출력해본결과 이상하게 7번째 태그값이 없더라고요 (All Remove 하게되면 7개의 뷰가 다사라짐)
그래서 FOR루프로 태그값 6개를 전부 제거시키려고 하는데 루프를 돌릴때 remove함수를 쓰지 않으면 6개 정상 출력되지만
remove 함수를 쓴뒤에 돌리면 6개중에 3개밖에 지워지지 않아요 그이유를 모르겠습니다.
remove 함수를 쓰지 않은 루프
int Child = Main_View.getChildCount();
for(int cnt=0; cnt<Child; cnt++)
{
Log.e("TAG", "제거된 TAG :" + Main_View.getChildAt(cnt).getTag() + "CNT:" + cnt + "Main_View.getChildCount():" + Main_View.getChildCount());
}
logcat
04-07 17:32:08.850 16058-16058/kr.qoop.contacts E/TAG﹕ 제거된 TAG 있나:Profile:0CNT:0Main_View.getChildCount():6
04-07 17:32:08.850 16058-16058/kr.qoop.contacts E/TAG﹕ 제거된 TAG 있나:Profile_Add:1CNT:1Main_View.getChildCount():6
04-07 17:32:08.850 16058-16058/kr.qoop.contacts E/TAG﹕ 제거된 TAG 있나:Profile_Add:2CNT:2Main_View.getChildCount():6
04-07 17:32:08.850 16058-16058/kr.qoop.contacts E/TAG﹕ 제거된 TAG 있나:Profile_Add:3CNT:3Main_View.getChildCount():6
04-07 17:32:08.850 16058-16058/kr.qoop.contacts E/TAG﹕ 제거된 TAG 있나:Profile_Add:4CNT:4Main_View.getChildCount():6
04-07 17:32:08.850 16058-16058/kr.qoop.contacts E/TAG﹕ 제거된 TAG 있나:Profile_Add:5CNT:5Main_View.getChildCount():6
remove를 쓴 루프
int Child = Main_View.getChildCount();
for(int cnt=0; cnt<Child; cnt++)
{
Main_View.removeView(Main_View.getChildAt(cnt));
Log.e("TAG", "제거된 TAG :" + Main_View.getChildAt(cnt).getTag() + "CNT:" + cnt + "Main_View.getChildCount():" + Main_View.getChildCount());
}
logcat
04-07 17:31:29.235 15894-15894/kr.qoop.contacts E/TAG﹕ 제거된 TAG 있나:Profile_Add:1CNT:0Main_View.getChildCount():5
04-07 17:31:29.235 15894-15894/kr.qoop.contacts E/TAG﹕ 제거된 TAG 있나:Profile_Add:3CNT:1Main_View.getChildCount():4
04-07 17:31:29.235 15894-15894/kr.qoop.contacts E/TAG﹕ 제거된 TAG 있나:Profile_Add:5CNT:2Main_View.getChildCount():3
왜 이런건지 모르겠습니다 ㅠ
// Child 지운 부분 code
public void mOnClick(View v)
{
switch (v.getId())
{
case R.id.Profile_Box_Okay:
Profile_Box_Flag=false;
Profile_Info_Layout.setVisibility(View.GONE);
BitmapDrawable Poto = (BitmapDrawable)((ImageView)findViewById(R.id.Profile_Poto)).getDrawable();
Bitmap poto= Poto.getBitmap();
Profile_Change_Set(RequestCode_code,poto,Profile_Name.getText().toString(),Profile_Phone.getText().toString());
Toast.makeText(Main.this,"Okay",Toast.LENGTH_SHORT).show();
int Child = Main_View.getChildCount();
for(int cnt=0; cnt<Child; cnt++)
{
Main_View.removeView(Main_View.getChildAt(cnt));
Log.e("TAG", "제거된 TAG :" + Main_View.getChildAt(cnt).getTag() + "CNT:" + cnt + "Main_View.getChildCount():" + Main_View.getChildCount());
}
break;
case R.id.Profile_Box_Cancel:
Profile_Box_Flag=false;
Profile_Info_Layout.setVisibility(View.GONE);
Toast.makeText(Main.this,"Cancel",Toast.LENGTH_SHORT).show();
break;
case R.id.Profile_Poto:
Toast.makeText(Main.this,"Poto",Toast.LENGTH_SHORT).show();
break;
}
}