2016-06-19 4 views
-1

3 행과 3 열의 버튼이 총 9 개의 버튼으로 이루어지기를 원한다고 가정 해 봅시다. 어느 위치의 버튼 하나가 제거되면 버튼을 한 번 누를 때마다 틈이 생기지 않도록 어떻게 이동해야합니까? 나는 활동에서 이것을 달성하기 위해 길고 아마도 불필요하게 복잡한 방법들을 생각할 수있다. 레이아웃 파일을 통해이 작업을 수행하는 간단한 방법이 있습니까? 당신이 안드로이드의 XML 코드를 통해 순수하게 그렇게 할 수 있지만,이 RecyclerView 사용할 수 있는지안드로이드 스튜디오 그리드 버튼 자동 정렬

답변

0

는 잘 모르겠어요 :

RecylerView recycler = findViewById(R.id.recyclerInActivity); 

//now create a GridLayoutManager 
GridLayoutManager gridLayoutManager = new GridLayoutManager(this); 

//set the gridLayoutManager's spanCount to 3 for 3 columns: 
gridLayoutManager.setSpanCount(3); 

//Now create your custom Adapter with an XML layout with a button and set the adapter 
recycler.setAdapter(myCustomAdapter); 

//When a view is removed, remove it from the data supply (e.g. arrayListOfData.remove(indexOfRemovedItem)) of the RecylerView.Adapter and then call: 
myCustomAdapter.notifyItemChanged(indexOfRemovedItem); 

을 RecyclerView 년대 RecyclerView의 레이아웃을 보장합니다 애니메이션에 새 항목 수에 적응 내장

관련 문제