Here's an idea I thought I'd throw out... Can you replace your notes
listview with a button or imagebutton that pops up a dialog with notes
in a listview?

On Mar 24, 9:24 am, Anil <[EMAIL PROTECTED]> wrote:
> Hi Dan,
> My workaround is to simply not allow more than one note - bad for my
> application :( (ExpandableListView is not appropriate). But this way,
> I can specify a fixed value layout_height="50dip". IMHO it is a bug.
>
> I opened a bug on this:http://code.google.com/p/android/issues/detail?id=512
>
> "when I try the workaround of having a dummy note -  so that at least
> one note is always present - it still gives an unspecified size error.
> Logically, this should have worked, right?
>
> I could be mistaken, but it seems the real problem is the inner
> ListView is not
> recalculating its size.  It is not expanding when it grows. It seems
> to be taking the
> values specified in the layout file, and not the current dynamic state
> at runtime."
>
> thanks,
> Anil
>
> On Mar 23, 3:09 pm, "Dan U." <[EMAIL PROTECTED]> wrote:
>
> > I'm going to suggest that it won't work. There might be a way, but I
> > think you'll spend too much time searching for it. Can you perhaps use
> > ExpandableListView?
>
> > On Mar 23, 1:04 pm, "Dan U." <[EMAIL PROTECTED]> wrote:
>
> > > Wait, I found why the items didn't show up. Missed some of your code
> > > changes.
>
> > > On Mar 23, 1:00 pm, "Dan U." <[EMAIL PROTECTED]> wrote:
>
> > > > Oddly enough, contrary to what the docs say, specifying a specific
> > > > height in pixels to the parent of your ListView did not let me use
> > > > wrap_content for height of the ListView. I still got the same error.
>
> > > > I still don't have an answer yet. I can make it work if I specify a
> > > > certain height to the ListView, but I never see any of the items in
> > > > the notes_list ListView. Anil, were you able to see any of those
> > > > items?
>
> > > > On Mar 23, 6:55 am, Anil <[EMAIL PROTECTED]> wrote:
>
> > > > > Thanks for your reply, but if you look at the previous posts in this
> > > > > thread, I did raise the question -
> > > > > How can you specify the height of a list when by definition, a list
> > > > > can have variable number of elements?
> > > > > I tried setting the height of the note i.e. EditText in code, but it
> > > > > failed.
> > > > > -
> > > > > Anil
>
> > > > > On Mar 22, 10:33 pm, joebowbeer <[EMAIL PROTECTED]> wrote:
>
> > > > > > Doesn't this note in the ListView documentation explain the problem:
>
> > > > > > "Note: You cannot use the value wrap_content for the
> > > > > > android:layout_height attribute of a ListView in XML if the parent's
> > > > > > size is also not strictly specified (for example, if the parent were
> > > > > > ScrollView you could not specify wrap_content since it also can be 
> > > > > > any
> > > > > > length. However, you can use wrap_content if the ListView parent 
> > > > > > has a
> > > > > > specific size, such as 100 pixels."
>
> > > > > > If so, you either need to specify an actual height in the notes_list
> > > > > > ListView or in its parent.
>
> > > > > > --Joe
>
> > > > > > On Mar 22, 7:49 pm, Anil <[EMAIL PROTECTED]> wrote:
>
> > > > > > > Here is an example program to demonstrate it.
> > > > > > > I have modified List8.java in APIDemos/Views/Lists.
>
> > > > > > > The objective is to add a list of notes to each photo in List8.
> > > > > > > So we have a list containing lists. Since the notes can be 
> > > > > > > variable
> > > > > > > size, we use
> > > > > > > wrap_content on the height.
>
> > > > > > > 1) In class PhotoAdapter line 91
>
> > > > > > > // added
> > > > > > >         ArrayAdapter<String> notesAdapter;
> > > > > > >         String[] notes = new String[] {"1111", "2222", "3333", 
> > > > > > > "4444",
> > > > > > > "5555"};
>
> > > > > > > // modified
> > > > > > >    public PhotoAdapter(Context c) {
> > > > > > >             mContext = c;
>
> > > > > > >             notesAdapter = new ArrayAdapter<String>
> > > > > > >             (mContext,android.R.layout.simple_list_item_1, notes);
> > > > > > >          }
>
> > > > > > > // modified
> > > > > > >         public View getView(int position, View convertView, 
> > > > > > > ViewGroup
> > > > > > > parent) {
>
> > > > > > >                 ViewInflate vi = (ViewInflate)
> > > > > > >                 
> > > > > > > mContext.getSystemService(Context.INFLATE_SERVICE);
> > > > > > >                 View photoWithNotes = vi.inflate(R.layout.notes, 
> > > > > > > null, null);
> > > > > > >                 ImageView i = (ImageView)
> > > > > > > photoWithNotes.findViewById(R.id.photo);
> > > > > > >                 ListView notesView = (ListView)
> > > > > > >                 photoWithNotes.findViewById(R.id.notes_list);
> > > > > > >                 notesView.setAdapter(notesAdapter);
>
> > > > > > >             // Make an ImageView to show a photo
> > > > > > >            // ImageView i = new ImageView(mContext);
>
> > > > > > >             i.setImageResource(mPhotos.get(position));
> > > > > > >             i.setAdjustViewBounds(true);
> > > > > > > //            i.setLayoutParams(new
> > > > > > > ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,
> > > > > > >   //                  LayoutParams.WRAP_CONTENT));
> > > > > > >             // Give it a nice background
> > > > > > >             i.setBackground(android.R.drawable.picture_frame);
> > > > > > >             return photoWithNotes;
> > > > > > >         }
>
> > > > > > > 2) added file notes.xml in res/layout
>
> > > > > > > <?xml version="1.0" encoding="utf-8"?>
>
> > > > > > > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> > > > > > > android"
> > > > > > >         android:orientation="vertical" 
> > > > > > > android:layout_width="fill_parent"
> > > > > > >         android:id="@+id/pictures"
> > > > > > >         android:layout_height="wrap_content">
>
> > > > > > >         <ImageView android:id="@+id/photo"
> > > > > > >                 android:layout_width="wrap_content"
> > > > > > >                 android:layout_height="wrap_content">
> > > > > > >         </ImageView>
> > > > > > >         <ListView android:id="@+id/notes_list"
> > > > > > >                 android:orientation="vertical" 
> > > > > > > android:layout_width="fill_parent"
> > > > > > >                 android:layout_height="wrap_content"
> > > > > > >                 android:scrollbars="horizontal|vertical"
> > > > > > >                  android:layout_weight="1.0" />
>
> > > > > > > </LinearLayout>
>
> > > > > > > 3) When you run it, clicking on New Photo gives the error "List 
> > > > > > > Views
> > > > > > > can't have unspecified
> > > > > > > size".
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to