Createpopup.xml 이라는 액티비티에서 버튼을 클릭하면
fragment_home.xml이라는 액티비티 내에 있는 id가 grouplist인 linearlayout안에
list_item 이라는 액티비티에 있는 코드를 추가시키고 싶은데
잘 안됩니다 ㅜㅜ
fragment_home 쪽에서는
Intent intent = new Intent(getActivity(), PopupCreateActivity.class);
Bundle bundle = new Bundle();
bundle.putInt("LIST_ID", R.id.grouplist);
intent.putExtras(bundle);
이런식으로 아이디를 보냈고
Createpopup 쪽에서는
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
int listID = bundle.getInt("LIST_ID", 0);
if (listID != 0) {
groupList = findViewById(listID);
Button createButton = findViewById(R.id.createbtn);
createButton.setOnClickListener(this);
}
}
이렇게 받았고
버튼쪽에는
@Override
public void onClick(View view) {
View customListItem = LayoutInflater.from(this).inflate(R.layout.list_item, groupList, false);
if (groupList == null) {
// groupList가 null인 경우 처리할 작업
// 예를 들어, Log 메시지 출력 또는 다른 초기화 작업 등을 수행할 수 있습니다.
Log.e("PopupCreateActivity", "groupList is null");
} else {
// groupList가 null이 아닌 경우
// groupList를 사용한 작업 수행
groupList.addView(customListItem);
}
}
이런 식으로 코드 짰는데 버튼을 눌러도 생성이 안됩니다 ㅠ
grouplist라는 아이디를 어떻게 가져와야 되는지 잘 모르겠습니다.