ArrayAdapter<T> / .toString question


#1

On page 182 is the statement:

The default implementation of ArrayAdapter.getView(…) relies on toString(). It inflates
the layout, finds the correct Crime object, and then calls toString() on the object to populate the
TextView.

I believe you, but how/from where do we know this? This seems to relate to some of the other issues I was having before, and would appreciate knowing where to look to get a better understanding. My google-fu is weak, couldn’t find any useful information on developers.android.com.

ie. How would we know that public String toString() was what needed to be Overridden?

Thanks.


#2

My standard google invocation is to simply scream, “GOOGLE, HOW DOES ARRAYADAPTER WORK??”

Well, not really. (I think they’re still working on that.) If I want to know details on ArrayAdapter, my first stop is usually to search for “ArrayAdapter android”, which will usually shoot you right to the reference documentation:

http://developer.android.com/reference/android/widget/ArrayAdapter.html

The information you’re looking for is in the discussion at the top of the page.


#3

I may have answered my own question. This is from CrimeFragment.java

	mTitleField = (EditText) v.findViewById(R.id.crime_title);
	mTitleField.addTextChangedListener(new TextWatcher() {
		public void onTextChanged(CharSequence c, int start, int before,
				int count) {
			[color=#0000FF][size=150]mCrime.setTitle(c.toString());[/size][/color]
		}

		public void beforeTextChanged(CharSequence c, int start, int count,
				int after) {
			// This space intentionally left blank
		}

		public void afterTextChanged(Editable c) {
			// This one too
		}
	});

Is that the answer to my inquiry?


#4

[quote=“phillips”]My standard google invocation is to simply scream, “GOOGLE, HOW DOES ARRAYADAPTER WORK??”

Well, not really. (I think they’re still working on that.) If I want to know details on ArrayAdapter, my first stop is usually to search for “ArrayAdapter android”, which will usually shoot you right to the reference documentation:

http://developer.android.com/reference/android/widget/ArrayAdapter.html

The information you’re looking for is in the discussion at the top of the page.[/quote]

Thanks. I started my other post before your reply posted. I thought I had looked there already, but it makes more sense now.

Thanks for the patience.