[android-developers] Is there a docment on getView()?

2012-01-05 Thread John Davis
Hello The getView() call for arrayadapter is blank. Is there a document which describes how it works? I have overridden it in order to change the text color of items in a list view. So far, I can't find any code which works. I've tried this: public class MyAdapterT extends ArrayAdapterT {

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread Kostya Vasilyev
1: http://developer.android.com/reference/android/widget/Adapter.html#getView(int, android.view.View, android.view.ViewGroup) 2: Yes, you're supposed to call the base class in your case, the ArrayAdapter will be doing most of the work for you, inflating new or reusing existing row layouts. 3:

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread TreKing
2012/1/5 John Davis davi...@gmail.com The getView() call for arrayadapter is blank. Is there a document which describes how it works? The docs are your friend: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List4.html I don't know if I am

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread John Davis
Hello Kostya, Thanks for the reply. On Thu, Jan 5, 2012 at 11:39 AM, Kostya Vasilyev kmans...@gmail.com wrote: 2: Yes, you're supposed to call the base class in your case, the ArrayAdapter will be doing most of the work for you, inflating new or reusing existing row layouts. Ok. I think I

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread John Davis
Hello I don't have resource id's for the individual row items. You should, it's your project. Super. That might help, but this example http://developer.android.com/resources/tutorials/views/hello-listview.html does not use id's for the individual list items. How would I do that? John --

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread Kostya Vasilyev
Just to clarify 2: I meant calling super.getView from your adapter's getView, assuming it's a subclass of ArrayAdapter. Do not call adapter.getView from outside the adapter's code, that's meaningless. Now the view ids What layout id do you use to initialize the adapter? Perhaps

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread TreKing
On Thu, Jan 5, 2012 at 10:49 AM, John Davis davi...@gmail.com wrote: Super. That might help, but this example http://developer.android.com/resources/tutorials/views/hello-listview.html does not use id's for the individual list items. How would I do that?

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread John Davis
Hello On Thu, Jan 5, 2012 at 11:53 AM, Kostya Vasilyev kmans...@gmail.com wrote: Just to clarify 2: I meant calling super.getView from your adapter's getView, assuming it's  a subclass of ArrayAdapter. Do not call adapter.getView from outside the adapter's code, that's meaningless. That

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread Mark Murphy
On Thu, Jan 5, 2012 at 12:04 PM, John Davis davi...@gmail.com wrote: Now the view ids What layout id do you use to initialize the adapter? Perhaps android.R.layout.something? I did :                MyAdapterString adapter = new MyAdapterString(this,android.R.layout.simple_list_item_1,

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread TreKing
On Thu, Jan 5, 2012 at 11:04 AM, John Davis davi...@gmail.com wrote: Or, is there a way to patch up this code to do what I want? Yes. It seems pretty trivial to do. It is once you get the hang of it. I don't understand why the hooks do not exist for what i want to do. They do, but

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread Kostya Vasilyev
Aha! android.R.layout.simple_list_item_1 is defined in the platform, you can find it under your Android sdk directory/platforms/platform-version/data/res/layout (that data/res is very useful to look up things): The whole layout is a TextView, and its id is @android:id/text1, which, on the Java

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread John Davis
Kostya, Tip of the hat to you. That worked. It will set all the items to blue text. I appreciate your help a lot. Now, is there a simple way to do this selectively? I saw you could tag items and then look based upon a tag. Perhaps that will work? I would prefer that the class which creates

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread Kostya Vasilyev
Ok, great. One simple thing you can do is to check the item's position, e.g. set odd items to blue and even items to red (just to pick an example). Beyond that, consider creating a proper data item class. The adapter's getView would then examine the data item at the requested position and make

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread John Davis
On Thu, Jan 5, 2012 at 12:44 PM, Kostya Vasilyev kmans...@gmail.com wrote: Ok, great. One simple thing you can do is to check the item's position, e.g. set odd items to blue and even items to red (just to pick an example). The only logic which knows the desired color is the main view which

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread TreKing
On Thu, Jan 5, 2012 at 12:43 PM, John Davis davi...@gmail.com wrote: The only logic which knows the desired color is the main view which populated the list view. Then pass the information along as you populate your views. It seems that android can not do what I desire. More likely, you

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread Kostya Vasilyev
Correct. Since Android is not true Java, you can't call methods of one object from another object. An unfortunate limitation that is hopefully fixed some day (version 19.0? Peppermint Pattie?) /tongue firmly planted in cheek You can call some methods of the activity from the adapter, or you

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread John Davis
Yes, I would think it is possible, but not in this version. Its possible to set all line items to the same value. However, its not possible to set the colors on a case by case value using the provided api. This code will set all the line items to blue: public View getView(int position,

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread Kostya Vasilyev
Yes it is possible to set colors on a case by case basis using the provided API. It's just that the provided API is not structured the way you expect. Create a data item class with fields to base the logic on Extend BaseAdapter Override getView Check the data item fields and make the decision

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread TreKing
On Thu, Jan 5, 2012 at 1:07 PM, John Davis davi...@gmail.com wrote: Yes, I would think it is possible, but not in this version. Its possible to set all line items to the same value. However, its not possible to set the colors on a case by case value using the provided api. Yes it is. Please

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread John Davis
Sadly I appreciate your help, but I don't think it will work. I've already done an override of the getview call. The higher level logic which knows which items can specify the draw color can not communicate it to the lower level. The code samples, i have seen set all the colors in a list. I

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread John Davis
Hello Treking, On Thu, Jan 5, 2012 at 2:17 PM, TreKing treking...@gmail.com wrote: On Thu, Jan 5, 2012 at 1:07 PM, John Davis davi...@gmail.com wrote: Yes, I would think it is possible, but not in this version. Its possible to set all line items to the same value. However, its not possible

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread Romain Guy
Please post the full stack trace of your exception. On Thu, Jan 5, 2012 at 11:28 AM, John Davis davi...@gmail.com wrote: Hello Treking, On Thu, Jan 5, 2012 at 2:17 PM, TreKing treking...@gmail.com wrote: On Thu, Jan 5, 2012 at 1:07 PM, John Davis davi...@gmail.com wrote: Yes, I would think

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread TreKing
On Thu, Jan 5, 2012 at 1:24 PM, John Davis davi...@gmail.com wrote: The higher level logic which knows which items can specify the draw color can not communicate it to the lower level. Yes it can. Unless this is a specific design restriction you've imposed, there is nothing in the language or

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread John Davis
Hello Romain Guy, How would I post the full stack trace? The logcat output? John On Thu, Jan 5, 2012 at 2:30 PM, Romain Guy romain...@android.com wrote: Please post the full stack trace of your exception. On Thu, Jan 5, 2012 at 11:28 AM, John Davis davi...@gmail.com wrote: Hello Treking,

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread John Davis
This is from the debug window in the call stack output. Thread [1 main] (Suspended (exception RuntimeException)) ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2663 ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent)

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread Romain Guy
This is not the stack trace generated by the exception. Look at the logs and find the complete stack trace with the type of exception generated and we'll get a better understanding of what's going on. On Thu, Jan 5, 2012 at 11:34 AM, John Davis davi...@gmail.com wrote: This is from the debug

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread Mark Murphy
Please allow the exception to continue, then use LogCat to examine the full stack trace. You will see two stanzas for the stack trace, the second one prefixed by Caused by:. Your code will appear in the Caused by: portion of the stack trace. 2012/1/5 John Davis davi...@gmail.com: This is from

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread TreKing
2012/1/5 John Davis davi...@gmail.com This is from the debug window in the call stack output. As you were told in your other thread, that is the wrong stack. Look for Caused by... - TreKing

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread TreKing
2012/1/5 John Davis davi...@gmail.com I'm not blaming anyone or the api. I am simply saying it has a bug. Someone might want to look into it. Jumping to the conclusion that it is a bug is blaming the API. It crashed! Can't be my fault! It's a bug! Did you even debug your issue? Yes it

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread Kostya Vasilyev
That's the debugger's stack trace, not the logcat stack trace. Press F8 a few times until your device displays the application stopped unexpectedly. Then check the logcat panel in Eclipse and post the entire stack trace, especially the stuff after Caused by: -- Kostya 5 января 2012 г.

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread John Davis
Hello Treking, Kostya, Romain-Guy, Ok, I removed the breakpoint, ran it, hit F8 until I got logcat output. I selected all the red/orange text and exported to a textfile. This is the result. (I hope I am giving you the answer you request) 01-05 14:57:39.163: W/dalvikvm(9183): threadid=1: thread

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread Kostya Vasilyev
6 января 2012 г. 0:02 пользователь John Davis davi...@gmail.com написал: Hello Treking, Kostya, Romain-Guy, 01-05 14:57:39.308: E/AndroidRuntime(9183): Caused by: java.lang.ClassCastException: java.lang.String 01-05 14:57:39.308: E/AndroidRuntime(9183): at

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread Kristopher Micinski
Well it goes to the adapter, which will return Objects, which you then must cast to the appropriate type, in your case it's obviously a String. As RomainGuy (whom you should listen to, right, as he is a framework engineer) said in the previous thread, you get the actual views from getChild, this

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread Romain Guy
Then the problem is exactly what others have described earlier in this thread. Your list adapter contains strings (and you should know what it contains since you created it) and you attempt to cast one of these strings into a View. On Thu, Jan 5, 2012 at 12:02 PM, John Davis davi...@gmail.com

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread John Davis
Hello Ok. So I appreciate the help. Here is the summary: for (int i=0;icount;i++) { // If it is the 2nd or 5th item, tag it so that it will be displayed in blue. if (i==2 || i==5) { listCount = adapter.getCount();

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread Kristopher Micinski
On Thu, Jan 5, 2012 at 2:18 PM, John Davis davi...@gmail.com wrote: Hello Ok. So I appreciate the help.  Here is the summary:            for (int i=0;icount;i++) {                // If it is the 2nd or 5th item, tag it so that it will be displayed in blue.                if (i==2 || i==5)

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread John Davis
Hello Kris, Yes, that is a good way to put it. Thanks for the info. John On Thu, Jan 5, 2012 at 3:37 PM, Kristopher Micinski krismicin...@gmail.com wrote: On Thu, Jan 5, 2012 at 2:18 PM, John Davis davi...@gmail.com wrote: Hello Ok. So I appreciate the help. Here is the summary:

Re: [android-developers] Is there a docment on getView()?

2012-01-05 Thread Kostya Vasilyev
In fact, the docs page for Adapter: http://developer.android.com/reference/android/widget/Adapter.html ... says this: An Adapter object acts as a bridge between an AdapterViewhttp://developer.android.com/reference/android/widget/AdapterView.html and the underlying data for that view. The