• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Help - drawing a circle and divide it.

yotam2010

Newbie
Hey,
I am a begginer developer for android and although i do understand some of the basic concept I have a problem with drawing.

I would love detailed explenation about how to create, display and divide a circle shape.
about what i try to do:
something like (or exactly) lucky wheel.
I want the user to choose a number between 1 to 10 then dynamicly a circle divided by the number he picked will be display. in each part I want a number to be displayed (1 to the number he picked).
then to rotate the circle randomly and get the number in ceratin aera..
something like this but with numbers:
36333917-rainbow-roulette-wheel-Stock-Vector-fortune.jpg
 
thanks, didnt read it yet but it looks promising!
btw i didnt started with it at all. dont really know how to use canvas / draw in general (yet).
i did figured out how to check which part (segmant) was chosen.
i plan to rotate the circle with 720-3600 degrees so all i need to do is to divide 1 in the number of segmants so for example
1/4 = 0.25
and then get the decimil of the degree / 360
for example
540 / 360 = 1.5
and then compare the decimil to the segmant size
so 0-0.25 = first segmant and 0.25-0.5 second segmant ETC
so in the above example its the second segmant.
 

btw i have another question if you can help me (same project but not really related).

I try to change the color of list item on long click. for some reason it color the item and every 4th item.
(color the item i pressed and every 4th item which is out side the screen when i scroll to it)
the code:

Java:
mQuestionListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
                @Override
                public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                    TextView textView = (TextView)view.findViewById(R.id.list_item_Question);
                        if(!mListItemPicked.contains(position)) {
                            mMenu.findItem(R.id.delete_Question_menu_item).setVisible(true);
                            mMenu.findItem(R.id.edit_Question_menu_item).setVisible(true);

                            textView.setBackgroundColor(Color.RED);
                            mListItemPicked.add(position);
                        }else{
                            textView.setBackgroundColor(Color.WHITE);
                            mListItemPicked.remove(mListItemPicked.indexOf(position));
                            if(mListItemPicked.size()==0){
                                mMenu.findItem(R.id.delete_Question_menu_item).setVisible(false);
                                mMenu.findItem(R.id.edit_Question_menu_item).setVisible(false);
                            }
                        }

                    return false;
                }
            });

the resault is something like:
View
View
View
View
View
View
View
 
It's happening because ListView uses View recycling when you scroll. For efficiency reasons, once a list item scrolls off the screen, it can be reused in an item coming on to the screen. If you've coloured the TextView (which is a child View of the row) red, then it will also show as red in the line which has been allocated the re-used View.

You need to implement a custom ListAdapter to have much more control over how your Views are reused, and set the properties as required.
 
Back
Top Bottom