[android-developers] Re: ListActivity, Cursor, and CursorAdapter
Please take the table in DB for example: ID Player_Name Score 1 Jim 10 2 Bill 20 3 Bob 15 4 Mike 9 In the ListActivity, I want it shows like: Rank Player_Name Score 1 Bill 20 2 Bob 15 3 Jim 10 4 Mike 9 On Thu, Apr 7, 2011 at 2:48 PM, android.xi...@gmail.com android.xi...@gmail.com wrote: In my game, a table is created with 3 columns, _id, player_name, score. It is easy to get the name and score, order by score desc, then get anther value rank. If I want to display the rank number in the list activity (which is not in the cursor, but the sequence of the records), is it possible to use the CursorAdapter to fulfill it? In my current design, I have to use the BaseAdapter and get all data out of the cursor and set them in a list, with the new rank column. It is possible, but I don't think it is a good idea. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: ListActivity, Cursor, and CursorAdapter
At last, I used the simplest way, extract all the data out of via the cursor, and then prepare the data list for my listactivity. It works. On Fri, Apr 8, 2011 at 1:51 AM, Nadeem Hasan nha...@nadmm.com wrote: Use the cursor position by calling Cursor.getPosition(). -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to pass configuration parameters to custom views during construction
Currently, I use this way, and it seems works. But there are shall be some better way, I think. public MyView(Context context, AttributeSet attrs) { super(context, attrs); //Get the value from Activity this.mInt = ((MyActivity)context).getMyInt()); } On Wed, Apr 6, 2011 at 1:48 PM, android.xi...@gmail.com android.xi...@gmail.com wrote: Hello Guys, I defined a customer view, e.g. MyView, which need to be constructed with some own parameter, e.g. line number in the view, an integer. The view will be employed by my activity, MyActivity. It seems that the View's constructors are fixed and will be called by the system, and I can do nothing on it. The question is: How to pass the integer to the view during construction from the activity, while I've known the integer in MyActivity? Thanks in advance. Mike -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to pass configuration parameters to custom views during construction
I defined the XML file and attributes, and can read the values from the attributes. But still there is another issue, How can I set the values in MyActivity? Thanks, Mike On Wed, Apr 6, 2011 at 2:37 PM, Zsolt Vasvari zvasv...@gmail.com wrote: Use custom attributes in the layout XML. You can declare them in attrs.xml. On Apr 6, 1:48 pm, android.xi...@gmail.com android.xi...@gmail.com wrote: Hello Guys, I defined a customer view, e.g. MyView, which need to be constructed with some own parameter, e.g. line number in the view, an integer. The view will be employed by my activity, MyActivity. It seems that the View's constructors are fixed and will be called by the system, and I can do nothing on it. The question is: How to pass the integer to the view during construction from the activity, while I've known the integer in MyActivity? Thanks in advance. Mike -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to pass configuration parameters to custom views during construction
I don't like it, either. On Wed, Apr 6, 2011 at 2:37 PM, Zsolt Vasvari zvasv...@gmail.com wrote: public MyView(Context context, AttributeSet attrs) { super(context, attrs); //Get the value from Activity this.mInt = ((MyActivity)context).getMyInt()); } That's just terrible, sorry. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to pass configuration parameters to custom views during construction
I want to set the value before the constructor MyView, so then the view instance is not ready yet. My plan is to set the value in attributes in MyActivity, and then in the constructor of MyView, the attributes will be used. The problem is how to set the value of custom attributes in MyActivity, before the view is constructed. On Wed, Apr 6, 2011 at 5:07 PM, Kumar Bibek coomar@gmail.com wrote: Expose methods in your custom view that activities can call directly. Kumar Bibek http://techdroid.kbeanie.com http://www.kbeanie.com On Wed, Apr 6, 2011 at 2:35 PM, Mike Bear android.xi...@gmail.com wrote: I defined the XML file and attributes, and can read the values from the attributes. But still there is another issue, How can I set the values in MyActivity? Thanks, Mike On Wed, Apr 6, 2011 at 2:37 PM, Zsolt Vasvari zvasv...@gmail.com wrote: Use custom attributes in the layout XML. You can declare them in attrs.xml. On Apr 6, 1:48 pm, android.xi...@gmail.com android.xi...@gmail.com wrote: Hello Guys, I defined a customer view, e.g. MyView, which need to be constructed with some own parameter, e.g. line number in the view, an integer. The view will be employed by my activity, MyActivity. It seems that the View's constructors are fixed and will be called by the system, and I can do nothing on it. The question is: How to pass the integer to the view during construction from the activity, while I've known the integer in MyActivity? Thanks in advance. Mike -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to pass configuration parameters to custom views during construction
The scenario is like the following: 1. MyView is one of the component in MyActivity. 2. MyActivity is created from other activity, with an intent containing all the information for the activity, including the parameter for MyView. 3. We shall pass the parameter to the constructor of MyView, for the construction of it. I thought of other ways, like use the shared preference, it seems also work. But not a good way. On Wed, Apr 6, 2011 at 5:42 PM, Kumar Bibek coomar@gmail.com wrote: I don't think there is any point in setting the values before the constructor. I can't think of a situation where you would want to do that. Kumar Bibek http://techdroid.kbeanie.com http://www.kbeanie.com On Wed, Apr 6, 2011 at 2:47 PM, Mike Bear android.xi...@gmail.com wrote: I want to set the value before the constructor MyView, so then the view instance is not ready yet. My plan is to set the value in attributes in MyActivity, and then in the constructor of MyView, the attributes will be used. The problem is how to set the value of custom attributes in MyActivity, before the view is constructed. On Wed, Apr 6, 2011 at 5:07 PM, Kumar Bibek coomar@gmail.com wrote: Expose methods in your custom view that activities can call directly. Kumar Bibek http://techdroid.kbeanie.com http://www.kbeanie.com On Wed, Apr 6, 2011 at 2:35 PM, Mike Bear android.xi...@gmail.comwrote: I defined the XML file and attributes, and can read the values from the attributes. But still there is another issue, How can I set the values in MyActivity? Thanks, Mike On Wed, Apr 6, 2011 at 2:37 PM, Zsolt Vasvari zvasv...@gmail.comwrote: Use custom attributes in the layout XML. You can declare them in attrs.xml. On Apr 6, 1:48 pm, android.xi...@gmail.com android.xi...@gmail.com wrote: Hello Guys, I defined a customer view, e.g. MyView, which need to be constructed with some own parameter, e.g. line number in the view, an integer. The view will be employed by my activity, MyActivity. It seems that the View's constructors are fixed and will be called by the system, and I can do nothing on it. The question is: How to pass the integer to the view during construction from the activity, while I've known the integer in MyActivity? Thanks in advance. Mike -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to pass configuration parameters to custom views during construction
In my scenario, MyView will be only used in MyActivity. In addition, it's also the simplest way. Thanks for your help On Wed, Apr 6, 2011 at 5:51 PM, Kostya Vasilyev kmans...@gmail.com wrote: Ah. Well, you could have a setSomething method in the view, and push the value from the activity's onCreate - as already suggested by Kumar. If MyView is only intended to be used by MyActivity, then your original code seems fine (getting the context, casting to MyActivity and getting the value). It's not pretty, and it's not pure, but why mess with something that works? -- Kostya 06.04.2011 13:47, Mike Bear пишет: The scenario is like the following: 1. MyView is one of the component in MyActivity. 2. MyActivity is created from other activity, with an intent containing all the information for the activity, including the parameter for MyView. 3. We shall pass the parameter to the constructor of MyView, for the construction of it. I thought of other ways, like use the shared preference, it seems also work. But not a good way. -- Kostya Vasilyev -- http://kmansoft.wordpress.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] How can I draw nice connections between two points in Android?
I tried the second with images, and it works well... Thanks, Mike On Wed, Mar 30, 2011 at 1:00 PM, Kristopher Micinski krismicin...@gmail.com wrote: I'm sure both solutions are *possible*... Implementation? Depends on what you want. Images would give you more prettiness, right? But maybe if you just had lines it would be more light weight. What's the purpose of it though, that might help give a better answer (or point you in a better direction perhaps). Kris On Wed, Mar 30, 2011 at 12:55 AM, Mike Bear android.xi...@gmail.comwrote: Hi Kris and all, As my understanding, there are maybe two possible solutions: 1. draw points by points, to render a connection like lightning (or river) between the two points p1 and p2. 2. draw image to between the two points; in the image, we can draw what we want. Do you think both solutions are possible, and if they are, which one is easier from implementation perspective? Thanks, Mike On Wed, Mar 30, 2011 at 12:27 PM, Kristopher Micinski krismicin...@gmail.com wrote: I mean, you could either do it yourself by making a lightning bolt with lines, or something nice like that. Or you can probably load a picture into memory and rotate / morph it. Did you mean shapes that were actual images, or something more like dotted lines (setting the pen differently) or curves? But is there built in Android support for something like drawRiver(p1,p2)? I'm not sure, but I don't think so. Kris On Tue, Mar 29, 2011 at 11:40 PM, android.xi...@gmail.com android.xi...@gmail.com wrote: For simplification, there are two points in the Canvas, p1 (x1, y1) and p2(x2, y2). I want to connect the two points with some kind of connections, which is not the drawLine function. In the connection, there are much nice effects (much beautiful) than only a simple line, for example, the connection between the two points are like the lighting, or looks like a river. Is there are any possibility to implement the effects? Thanks in advance. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Suggestions on best way to draw a laser in a 2d game
Sounds interesting about your implementation. How many lines of code do you wrote for the C# lightning? How about it compared to the bitmap version? Thanks, On Fri, Feb 4, 2011 at 11:41 PM, niko20 nikolatesl...@yahoo.com wrote: Peter's idea sounds like a good one to start with to try and see if you like it. For the best realism though I think a bitmap would be the solution. You don't have to rotate the bitmap - just make a bitmap that is known as a billboard (google billboarding graphics), with some alpha in it. (Although maybe the alpha will slow render time way down, don't know). Then you just do a quick loop from point A to point B, calculate the positions yourself (use slope of the line equations) and blit the bitmap over and over. You can also have two bitmaps, one pulsed and the other not, and then just cycle between them at a determined rate. The blitted bitmaps will overlap each other and form a type of particle beam effect. Although for a laser maybe Peter's solution is best, my bitmap idea would be more like a particle beam type thing. I've used this technique to create lightning for a game I wrote a long time ago in C#, worked really well. (To create lighting I randomized some of the points between A and B to move around) -niko On Feb 3, 8:05 pm, Peter Webb r.peter.w...@gmail.com wrote: I bet you can make a pretty funky laser beam using the draw lines or fill polygon commands in the Canvas/Paint library. To draw basic unpulsed laser beam draw a transparent line of width 6 between a and b. Then draw on top an opaque line of width 2 between a and b. You will get an effect where the laser beam falls off in brighness from the centre to the edges. To pulse it, draw a short line segment of width (say) 8 on top of the unpulsed laser beam, and move its position between a and b every screen refresh so the pulse moves along the line. If you want your laser beam to be some shape other than a long thin rectangle, you can do the same thing with a polygon fill command and you can have the laser beam whatever shape and size you want. On Feb 3, 7:38 pm, Mando mando.aka.ch...@gmail.com wrote: Hi, hope this is the right location to post this. I am working on a 2d android game with a light space shooter theme. I wanted my ship to have a turret the that tracks targets, rotates and fires a laser beam that is animated (maybe pulsing or with non uniform bulges issuing out of the turret and moving down towards the target). Key parts of the problem. laser starts at 1 coordinate and terminates at another in 2d space and could be of arbitrary length (might be scaled if I decide to add zooming). Possible brute force solutions: 1) using rotation/transformation to manually draw a bitmap representing a segment of laser all along the required distance. (cycling the bitmap as required for animation) 2) Create a very large laser beam image (longer than I would need eg: 10px by 500px) and draw it at correct transformation. Looking at the BitmapShader and reading some of the SDK info about Paths, Paints etc it feels like there should be a better way to do this, but no examples I've found covers it. Any idea if there is a way to use a BitmapShader to paint using a canvas.drawLine or canvas.drawPath call to create this effect? Thanks in advance Mando -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] How can I draw nice connections between two points in Android?
Hi Kris and all, As my understanding, there are maybe two possible solutions: 1. draw points by points, to render a connection like lightning (or river) between the two points p1 and p2. 2. draw image to between the two points; in the image, we can draw what we want. Do you think both solutions are possible, and if they are, which one is easier from implementation perspective? Thanks, Mike On Wed, Mar 30, 2011 at 12:27 PM, Kristopher Micinski krismicin...@gmail.com wrote: I mean, you could either do it yourself by making a lightning bolt with lines, or something nice like that. Or you can probably load a picture into memory and rotate / morph it. Did you mean shapes that were actual images, or something more like dotted lines (setting the pen differently) or curves? But is there built in Android support for something like drawRiver(p1,p2)? I'm not sure, but I don't think so. Kris On Tue, Mar 29, 2011 at 11:40 PM, android.xi...@gmail.com android.xi...@gmail.com wrote: For simplification, there are two points in the Canvas, p1 (x1, y1) and p2(x2, y2). I want to connect the two points with some kind of connections, which is not the drawLine function. In the connection, there are much nice effects (much beautiful) than only a simple line, for example, the connection between the two points are like the lighting, or looks like a river. Is there are any possibility to implement the effects? Thanks in advance. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en