开发者

How do I use hash-maps correctly when programming for Android?

I was told that I have to use a 开发者_开发问答hash-map to store radio buttons. (The buttons as the key and their state as value) but I am new to Java and Android so It's kinda confusing.

I have a choice test with multiple questions and yes or no answers and I want to count the yes answers.

Maybe it's some simple thing to do but I can't figure out.

Any help would be appreciated.

Thanks


You could add a reference to all of your objects to a collection and iterate over them checking whether they are checked and counting them up.

Alternatively you could register an onClick listener on all of the buttons and increment/decrement a count when they are clicked.

There are multiple ways you could achieve this. I dont see why you need a hash map though, as the checked state is available on the button object itself. Your hash is useless.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜