[android-developers] Need help using hat to track down memory usage

2008-11-05 Thread Disco Stu 010

Hello,

While perusing the source code, came across a shell function that  
envsetup.sh defines called runhat. Judging by the parameters, etc.,  
to this function, it allows one to get a heap-dump for a given  
application. This dump can then be analyzed by the tools hat and  
jhat.

Has anyone had any luck running these tools? I tried earlier today and  
consistently get an error message

Started HTTP server on port 7000
Reading from /tmp/t.hat...
java.io.IOException: Version string not recognized at byte 17
at hat.parser.HprofReader.readVersionHeader(HprofReader.java:325)
at hat.parser.HprofReader.read(HprofReader.java:169)
at hat.parser.Reader.readFile(Reader.java:90)
at hat.Main.main(Main.java:149)

I have tried jhat (built into Java SE 6.0) as well as hat (downloaded  
from https://hat.dev.java.net/). Both versions get the same error.

Can anyone help?

Thanks,
DS.





--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: ListView - If you have a item that can focus you can select the Item

2008-10-14 Thread Disco Stu 010

Hi Romain Guy,

What is the attribute you mention below that makes ListView items  
selectable or focusable? i.e., how/what does one change to make  
ListView items focusable by default (and not selectable)?

Thanks,
Nitin.

On Aug 27, 2008, at 1:28 PM, Romain Guy wrote:


 So, in conclusion, I can have a focusable item or a focusable child
 into the item but not both.

 No, items in a ListView are not focusable by default, they are
 selectable. So an item can be focusable (it gets focus or one of its
 children gets focus) OR selectable, but not both. You can make the
 item and its children focusable if you want. But keyboard focus
 navigation might not work properly in that case (overlapping focusable
 items are not handled very well for now.)


 That means, for example, that if I want to have a list of songs,  
 where
 if I select one I play it, and each one have a button to add to one
 playlist is not possible?

 And another quick question, Can I have a SurfaceView able to display
 videos and photos?, lets say, for example, that I want to put a
 loading image while downloading the video, is that possible? (using
 MediaPlayer yo play the video).

 Thanks.





 -- 
 Romain Guy
 www.curious-creature.org

 


--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] ViewGroup and LayoutAnimation question

2008-10-08 Thread Disco Stu 010
Hello,

A question on how a Layout animation works with a ViewGroup object  
such as a ListView. As shown in many ApiDemo examples, when the screen  
is first rendered/layed-out, the animation sequence runs nicely. How  
can one get the Layout animation to re-play on demand. I have tried  
two different mechanisms

LayoutAnimationController lac = vg.getLayoutAnimation ();
lac.start();

as well as a simple
vg.requestLayout();

thinking that the latter will simply cause the whole ViewGroup to re- 
render and therefore replay the animation. Neither of these seems to  
work.

Any ideas?

Thanks,
DS.




--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Programmatic scrolling of a ListView?

2008-10-07 Thread Disco Stu 010

Hello,

  When we use setSelectionFromTop(), the list adjusts itself so that  
the selection is positioned some y pixels from the top. However, this  
happens in a somewhat 'sudden' manner. Is it possible to make this  
animated where the list appears to smoothly scroll and then settles in  
its final position?

Thanks,
DS.


--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] WebView unable to display www.google.com?

2008-09-22 Thread Disco Stu 010
Hi,

Here is a simple test activity that is unable to show www.google.com.  
However, www.yahoo.com shows properly. It is strange that the same  
URL, http://www.google.com/;  renders just fine in the web browser  
application built into the SDK.

Any ideas?

Thanks,
DS.


public class WebViewTestActivity extends Activity {

/* (non-Javadoc)
 * @see android.app.Activity#onCreate(android.os.Bundle)
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

WebView wv = new WebView(this);
wv.loadUrl(http://www.google.com;);

setContentView (wv);
}

}
-
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: WebView unable to display www.google.com?

2008-09-22 Thread Disco Stu 010

As always, Mark Murphy to the rescue. Thanks a bunch, Mark.

Regards,
DS.

PS: Any thoughts on another problem I posted earlier about focus  
issues when a WebView partially obscures a ListView? - DS.

On Sep 22, 2008, at 3:55 PM, Mark Murphy wrote:


 Here is a simple test activity that is unable to show www.google.com.
 However, www.yahoo.com shows properly. It is strange that the same
 URL, http://www.google.com/;  renders just fine in the web browser
 application built into the SDK.

 This baffled me for the longest time, but somebody pointed out the  
 issue a
 month or two ago.

 The Google home page uses Javascript, and WebView does not have  
 Javascript
 enabled by default.

 Use WebSettings to enable Javascript, and the Google home page  
 should then
 work.

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com
 _The Busy Coder's Guide to Android Development_ Version 1.2 Published!



 


--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Bug in focus handling between WebView and ListView

2008-09-20 Thread Disco Stu 010
Hello folks,

There appears to be a bug in focus handling when a WebView is  
partially overlapping a ListView. I am able to reproduce this problem  
via  a simple change to one of the ApiDemos example.

If you change the file ApiDemos/res/layout/linear_layout_9.xml to be  
as given below, and run the demo Views/Layouts/LinearLayout/9.Layout  
Weight, this change causes a WebView to be overlaid on top of the  
list such that the list is partially obscured. Now, any mouse motions  
on top of the WebView seem to make their way to the ListView. The  
embedded WebView object never gets focus. for example, one can hold  
the mouse on top of the WebView and cause the ListView (which is  
obscured) to respond to scrolling action. If you replace the WebView  
with a TextView instead, then the TextView intercepts all mouse events  
as expected.

Any thoughts on where this bug lies and potential workarounds will be  
greatly appreciated.

Thanks,
DS.

---linear_layout_9.xml---
?xml version=1.0 encoding=utf-8?
!--
 Demonstrates a simple linear layout. The layout fills the screen,  
with the
 children stacked from the top.
 --
AbsoluteLayout xmlns:android=http://schemas.android.com/apk/res/android 

 android:orientation=vertical
 android:layout_width=fill_parent
 android:layout_height=fill_parent

 ListView android:id=@+id/list
 android:layout_width=fill_parent
 android:layout_height=wrap_content
 android:layout_weight=1.0 /

 Button
 android:layout_width=fill_parent
 android:layout_height=wrap_content
 android:text=@string/linear_layout_9_button /

WebView
android:layout_width=fill_parent
android:layout_height=fill_parent
android:layout_x=500px
android:layout_y=200px
android:background=#
android:clickable=true
/

/AbsoluteLayout
!--
  * Copyright (C) 2007 Google Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  --




--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Question about NPE in AdapterView.rememberSyncState()

2008-08-26 Thread Disco Stu 010

Hello,

Hoping for an answer from the Android team on this one.  Could you  
please shed some light on the following NPE?

ERROR/AndroidRuntime(1789): java.lang.NullPointerException
ERROR/AndroidRuntime(1789): at  
android.widget.AdapterView.rememberSyncState(AdapterView.java:799)
ERROR/AndroidRuntime(1789): at android.widget.AdapterView 
$MyDataSetObserver.onChanged(AdapterView.java:548)
ERROR/AndroidRuntime(1789): at  
android 
.database.DataSetObservable.notifyChanged(DataSetObservable.java:29)
ERROR/AndroidRuntime(1789): at  
android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:42)

It started showing up in my code rather mysteriously. Also there does  
not seem to be any usage pattern that atleast I can discern.

Any ideas on what might be causing this?

Thanks a bunch.

Regards,
DS.

PS: This is on the M5 SDK - DS

--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
Announcing the new Android 0.9 SDK beta!
http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Is a Dialog completely modal?

2008-07-10 Thread Disco Stu 010

Hi Hackbod,

Thanks a bunch. That fixed it.

The method setFlags() has a second argument to it called mask, it  
works when I pass it 0x and not 0. I take it that is expected.

Thanks,
DS.

On Jul 9, 2008, at 5:18 PM, hackbod wrote:


 You can do this to make it non-modal for touch events:

 Dialog 
 .getWindow 
 ().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);

 On Jul 9, 8:09 am, Disco Stu 010 [EMAIL PROTECTED] wrote:
 Hi,

 Have a question w.r.t the Dialog object. Is it at all possible to  
 have
 a Dialog object overlaid on an Activity such that if a touch event is
 registered outside the bounds of the Dialog, then the event is sent  
 to
 the View behind the Dialog. From what little experiments I have done,
 it appears that a Dialog is completely modal and consumes every event
 on the screen. There does not seem to be a way to hand the event off
 to other view objects.

 Any thoughts?

 Thanks,
 DS.
 


--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Is a Dialog completely modal?

2008-07-09 Thread Disco Stu 010

Hi,

Have a question w.r.t the Dialog object. Is it at all possible to have  
a Dialog object overlaid on an Activity such that if a touch event is  
registered outside the bounds of the Dialog, then the event is sent to  
the View behind the Dialog. From what little experiments I have done,  
it appears that a Dialog is completely modal and consumes every event  
on the screen. There does not seem to be a way to hand the event off  
to other view objects.

Any thoughts?

Thanks,
DS.


  

--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] How does deleteRow work in a Cursor object

2008-07-08 Thread Disco Stu 010

Hello,

Hope some experts can shed light on the workings of a Cursor object.

Lets refer to the NotesList sample project accompanying the SDK. Here  
we have a ContentProvider that returns the results of a query as a  
Cursor object. The recipient of the Query can use this Cursor object  
whichever way it wants including making a deleteRow call.

Now, according to the documentation, deleteRow is supposed to delete a  
row from the underlying datastore. How does the Cursor know what  
table/row the cursor correspond to? I tried to single-step through the  
NotesList application and the delete method belonging to the  
DataProvider class, NotePadProvider is not used at all. How does the  
Cursor end up bypassing the DataProvider responsible for the Database?

Further more, the cursor can be the result of a complex join query  
in which case, how would anyone know which row to delete?

Any insights will be greatly appreciated.

Mark Murphy, any thoughts? :)

Thanks,
DS.

--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How does deleteRow work in a Cursor object

2008-07-08 Thread Disco Stu 010

Hey Mark,

Thanks again. I had reached the same conclusion as you that   
Cursor.deleteRow() should result in a DataProvider.delete with some  
URI. However, I dont see that happening. I added a Log.w statement to  
query(), insert(), delete() and update() methods of the data provider  
and only query() and insert() are being called.

Maybe some Android team members can shed light on this?

Thanks,
DS.

PS: BTW, I am able to single-step through the debugger on insert so  
atleast in this case, the debugger seems to work - NS.


On Jul 8, 2008, at 3:39 PM, Mark Murphy wrote:


 Mark Murphy, any thoughts? :)

 blink, blink

 Thanks for the vote of confidence! Though, bear in mind, I'm not an
 Android team member, nor do I play one on TV.

 Now, according to the documentation, deleteRow is supposed to  
 delete a
 row from the underlying datastore. How does the Cursor know what
 table/row the cursor correspond to?

 It's been a while since I looked at NotePad, so forgive me if I mis- 
 speak
 here...

 NotePad uses a ContentProvider (NotePadProvider), so the Cursor you're
 presumably referring to is the one in the activity showing the notes
 (e.g., NotesList). In that case, the Cursor isn't directly accessing  
 the
 database (a la SQLiteCursor), but rather wraps the Intent-laden IPC
 mechanism that Android has...somewhere...that bridges between the  
 Cursor
 and the ContentProvider interface supported by the NotePadProvider.
 Content providers may not be in-process, particularly if they're  
 supplied
 by some other application than your own.

 When you call deleteRow() on the Cursor, the Cursor does not know the
 table/row, as the Cursor has no idea how the ContentProvider is  
 providing
 the content: SQLite? in-memory data? random-data generator?

 What the Cursor *does* know, though, is the Uri of the piece of  
 content
 the Cursor presently points to. On a deleteRow(), that Uri eventually
 winds up as a parameter to the delete() method on the NotePadProvider
 (again, via Androidy IPC goodness). It is up to NotePadProvider to  
 parse
 that Uri and determine the appropriate table/row.

 I tried to single-step through the
 NotesList application and the delete method belonging to the
 DataProvider class, NotePadProvider is not used at all.

 I find that somewhat difficult to believe. Maybe the debugger  
 doesn't step
 through the Android innards as Cursor#deleteRow() goes through the  
 IPC to
 get to ContentProvider#delete().

 Further more, the cursor can be the result of a complex join query
 in which case, how would anyone know which row to delete?

 If you do a complex join while query()-ing
 content://com.google.provider.NotePad/notes, and you get back rows  
 with
 IDs of 4, 8, 15, 16, 23, and 42, the Cursor turns those into Uri  
 instances
 like content://com.google.provider.NotePad/notes/4 and so on.

 When it comes to Cursors and ContentProviders, the Uri is your friend.

 -- 
 Mark Murphy (a Commons Guy)
 http://commonsware.com
 _The Busy Coder's Guide to Android Development_ -- Available Now!


 


--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How does deleteRow work in a Cursor object

2008-07-08 Thread Disco Stu 010

Hi,

I see...Is this to make the behavior more consistent?

If it gets deprecated, then when a Cursor is being used as a  
ListAdapter and an entry needs to be deleted, would we take the  
following steps?

1. Issue a delete() to the DataProvider with the appropriate URL and  
the relevant parameters.
2. Issue a Cursor.requery() to get the List to refresh itself
OR
2. Reissue the query to get a new Cursor and use that to create a new  
ListAdapter.


Thanks,
DS.


On Jul 8, 2008, at 7:16 PM, Romain Guy wrote:


 Hi,

 Cursor.deleteRow() will be deprecated in or removed from the next SDK.

 On Tue, Jul 8, 2008 at 4:10 PM, Disco Stu 010  
 [EMAIL PROTECTED] wrote:

 Hey Mark,

 Thanks again. I had reached the same conclusion as you that
 Cursor.deleteRow() should result in a DataProvider.delete with some
 URI. However, I dont see that happening. I added a Log.w statement to
 query(), insert(), delete() and update() methods of the data provider
 and only query() and insert() are being called.

 Maybe some Android team members can shed light on this?

 Thanks,
 DS.

 PS: BTW, I am able to single-step through the debugger on insert so
 atleast in this case, the debugger seems to work - NS.


 On Jul 8, 2008, at 3:39 PM, Mark Murphy wrote:


 Mark Murphy, any thoughts? :)

 blink, blink

 Thanks for the vote of confidence! Though, bear in mind, I'm not an
 Android team member, nor do I play one on TV.

 Now, according to the documentation, deleteRow is supposed to
 delete a
 row from the underlying datastore. How does the Cursor know what
 table/row the cursor correspond to?

 It's been a while since I looked at NotePad, so forgive me if I mis-
 speak
 here...

 NotePad uses a ContentProvider (NotePadProvider), so the Cursor  
 you're
 presumably referring to is the one in the activity showing the notes
 (e.g., NotesList). In that case, the Cursor isn't directly accessing
 the
 database (a la SQLiteCursor), but rather wraps the Intent-laden IPC
 mechanism that Android has...somewhere...that bridges between the
 Cursor
 and the ContentProvider interface supported by the NotePadProvider.
 Content providers may not be in-process, particularly if they're
 supplied
 by some other application than your own.

 When you call deleteRow() on the Cursor, the Cursor does not know  
 the
 table/row, as the Cursor has no idea how the ContentProvider is
 providing
 the content: SQLite? in-memory data? random-data generator?

 What the Cursor *does* know, though, is the Uri of the piece of
 content
 the Cursor presently points to. On a deleteRow(), that Uri  
 eventually
 winds up as a parameter to the delete() method on the  
 NotePadProvider
 (again, via Androidy IPC goodness). It is up to NotePadProvider to
 parse
 that Uri and determine the appropriate table/row.

 I tried to single-step through the
 NotesList application and the delete method belonging to the
 DataProvider class, NotePadProvider is not used at all.

 I find that somewhat difficult to believe. Maybe the debugger
 doesn't step
 through the Android innards as Cursor#deleteRow() goes through the
 IPC to
 get to ContentProvider#delete().

 Further more, the cursor can be the result of a complex join  
 query
 in which case, how would anyone know which row to delete?

 If you do a complex join while query()-ing
 content://com.google.provider.NotePad/notes, and you get back rows
 with
 IDs of 4, 8, 15, 16, 23, and 42, the Cursor turns those into Uri
 instances
 like content://com.google.provider.NotePad/notes/4 and so on.

 When it comes to Cursors and ContentProviders, the Uri is your  
 friend.

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com
 _The Busy Coder's Guide to Android Development_ -- Available Now!










 -- 
 Romain Guy
 www.curious-creature.org

 


--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] How does ListActivity create multiple list items

2008-07-01 Thread Disco Stu 010

Hello,

A question for the experts on how ListActivity does its job.

My understanding of the documentation is that to give a custom look to  
ListActivity, one needs to provide a template View (through  
setContentView) that contains a ListView object with the ID list.  
ListActivity then proceeds to use this template for all the rows it  
displays.

My question is, how does ListActivity create multiple instances of  
these ListView objects? (one for each row)  If using the  
findViewById() method, one ends up with a single View object. Is  
there a straightforward way to create clones of a view object?

Any insights will be greatly appreciated.  I would like to do  
something similar but with a TableLayout. Specify a template for each  
column in the table and be able to instantiate view objects for each  
table cell.

Thanks,
DS.




--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How does ListActivity create multiple list items

2008-07-01 Thread Disco Stu 010

Hey Mark,

Thanks for the explanation. Most helpful. I now understand that one  
can have any view to render a row by overriding the getView() method.

My original question though still stays. If given a resource id for  
a view, how can one create multiple instances of that view? Can I  
simply call findViewById() multiple times to get different instances  
or do they return the same copy of the View object?

Thanks,
DS.

PS: Looking forward to your tutorial - DS

On Jul 1, 2008, at 1:30 PM, Mark Murphy wrote:


 My understanding of the documentation is that to give a custom look  
 to
 ListActivity, one needs to provide a template View (through
 setContentView) that contains a ListView object with the ID list.
 ListActivity then proceeds to use this template for all the rows it
 displays.

 Close. There are actually two layouts you provide: one for the  
 activity,
 and one for the rows.

 The one for the activity needs to have a ListView with the  
 android:id of
 list. You connect this layout to the activity via  
 setContentView(), like
 you would for any other activity.

 The constructor of the Adapter you use with your ListView will take  
 the
 R.layout name of a second layout, this one for the rows.

 You are also welcome to override getView() on the Adapter, which will
 ignore the second layout and allow you to construct the rows by  
 whatever
 means you see fit (manual constructors, ViewInflate, etc.).

 Later this month, I'll be writing up a tutorial on AndroidGuys about  
 all
 this.

 -- 
 Mark Murphy (a Commons Guy)
 http://commonsware.com
 _The Busy Coder's Guide to Android Development_ -- Available Now!


 


--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How does ListActivity create multiple list items

2008-07-01 Thread Disco Stu 010

Hi Mark,

Thanks for the detailed explanation. This helps tremendously.

Can you please also clarify what do you mean by use the same instance  
as the convertView parameter? Dont I need a new View instance for  
every cell being displayed? i.e., if displaying 5 TextView rows at the  
same time, then do we need need 5 different instances of TextView? OR  
is it the case that the getView() method is called only when the View  
is about to be drawn and therefore a single instance will suffice for  
displaying the whole list ?

Thanks,
Nitin.


On Jul 1, 2008, at 3:19 PM, Mark Murphy wrote:


 Thanks for the explanation. Most helpful. I now understand that one
 can have any view to render a row by overriding the getView() method.

 Or by supplying your own layout XML identifier
 (R.layout.somethingoranother), if the rows are reasonably simple.  
 I'm a
 bit of a control freak, so I prefer overriding getView(), but that's  
 just
 me.

 My original question though still stays. If given a resource id for
 a view, how can one create multiple instances of that view?

 http://code.google.com/android/reference/android/view/ViewInflate.html

 ViewInflate#inflate() will create a new View based on a supplied  
 resource ID.

 For example:

 ViewInflate inflater=getViewInflate(); // assumes you're in an  
 Activity
 View view=inflater.inflate(R.layout.tourview_std, null, null);
 TextView distance=(TextView)view.findViewById(R.id.distance);
 ImageView turn=(ImageView)view.findViewById(R.id.turn);
 ImageView marker=(ImageView)view.findViewById(R.id.marker);
 TextView waypoint=(TextView)view.findViewById(R.id.waypoint);

 Here, I inflate R.layout.tourview_std, then use findViewById() to  
 get at
 the innards. I can then set the text and images as needed.

 For better performance, examine the View convertView parameter  
 passed into
 your getView() callback. If it's the right View to use (e.g., you're  
 only
 inflating one type of row), then just reuse that instance, since  
 it's one
 you inflated earlier. If it's null or the wrong view (e.g., you've got
 several types of rows, each with different layouts), inflate  
 yourself a
 new one. The inflation process isn't the speediest, so the fewer  
 inflates
 you can do, the better.

 Hope this helps!

 -- 
 Mark Murphy (a Commons Guy)
 http://commonsware.com
 _The Busy Coder's Guide to Android Development_ -- Available Now!


 


--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How does ListActivity create multiple list items

2008-07-01 Thread Disco Stu 010

Hi Mark,

I think I got it now :)

Thanks a bunch for all your help.

Regards.

On Jul 1, 2008, at 4:19 PM, Mark Murphy wrote:


 Can you please also clarify what do you mean by use the same  
 instance
 as the convertView parameter? Dont I need a new View instance for
 every cell being displayed? i.e., if displaying 5 TextView rows at  
 the
 same time, then do we need need 5 different instances of TextView? OR
 is it the case that the getView() method is called only when the View
 is about to be drawn and therefore a single instance will suffice for
 displaying the whole list ?

 Ideally, Android and your activity will only create as many row  
 Views as
 can be physically displayed by the ListView.

 Suppose you have an Adapter that wraps a set of 50 objects, but the
 ListView only has room to show 7 of those at a time. When your  
 activity
 launches, I believe your Adapter will have getView() called 7 times  
 with a
 null convertView, which you will wind up populating with the first 7
 objects' data out of the 50 available objects. Then, if the user  
 scrolls
 the ListView, your getView() will start being called with convertView
 sometimes being non-null, meaning the ListView wants to fill in an
 existing row's View with new data.

 I imagine the precise details on when getView() will be called with a
 possible-to-recycle convertView will vary as Android evolves.  
 However, if
 you get a non-null convertView, Android is asking you to recycle  
 that View
 if possible. Either return convertView (after modifying the contents  
 to
 reflect the data identified by the supplied position), or return a
 brand-new View, as your activity sees fit.

 At the outset, it may be simplest to ignore convertView and just  
 inflate
 new Views on each getView() call. If performance suffers, you can  
 always
 try reusing convertView.

 -- 
 Mark Murphy (a Commons Guy)
 http://commonsware.com
 _The Busy Coder's Guide to Android Development_ -- Available Now!


 


--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Question about LayoutAnimation2.java from the ApiDemos sample project

2008-06-27 Thread Disco Stu 010

Hi,

Thanks for your response. Certainly clarifies a few things.

The sample code has been immensely valuable in getting a better  
understanding of the Android APIs. I totally understand the 'too many  
things to do' problem, I have been guilty of that many times. However,  
I would like to respectfully submit that a very large community of  
developers is potentially relying on ApiDemos code to learn about  
Android. Well documented code should be a key element of the  
delivery and not simply whether the demo code works or not. There is a  
lot of power behind the few lines of code that is not apparent at all.  
Honestly, by 1.0 timeframe a large number of us might not even need to  
look at this code. Now is when the comments will be most helpful.

Thanks again,

DS.

On Jun 26, 2008, at 8:55 PM, hackbod wrote:


 On Jun 26, 1:24 pm, Romain Guy [EMAIL PROTECTED] wrote:
 - Why is the ApiDemos code not commented at all? (this one is an  
 extra
 credit question)
 Too many things to do :)

 And we can continue to put comments in sample code after completing
 the final code for 1.0, so it is pretty low in priority at this
 time. :)

 


--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---