2016-06-19 14 views
-1

3行3列のボタンが必要なので、合計9個のボタンが必要です。いずれかの位置にあるボタンが1つ削除された場合、そのボタンがどこにずれていないように、どのようにシフトするのですか?私は、アクティビティでこれを達成するために、長くて、おそらく不必要に複雑な方法を考えることができます。レイアウトファイルからこれを行う簡単な方法はありますか?あなたは、AndroidでXMLコードを純粋にそれを行うことができますが、あなたはRecyclerView使用できるかどうAndroidスタジオグリッドボタンの自動配置

答えて

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のレイアウトを確保するアニメーションに新しい項目数に適応建て

関連する問題