Android uses GridView to realize radio selection function

Let's take a look at the radio selection effect achieved by GridView

If you need it, you can continue to look down

The implementation is relatively simple, and the code is directly

The layout of the main activity. A button is used to jump to the filtered activity, and a textview is used to display the filtered results

Mainactivity your code logic, comments have been added

Then, filter activities. In the layout, a GridView is used to display the options to be selected, and a button is used to click to return to the main activity and bring the selected value

Then there is the filter logic

The main state changes are still in the adapter

And the item layout

If you want to click the jump to select Activity and the button to be filtered, show that the state of the button that you selected before is selected. It is also very simple. As long as you cache the position after you select it, point it in to filter Activity, instantiate Adapter and use mAdapter.changeState (position). Just pass the position of the button you need to change the state

For other details, please download the demo

Click download demo

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>