Ok, I created a new adapter which works. But now I've got the problem
that I want to add a onclick feature what means that if I click on one
item then a list will be shown. I've already found some examples in
the internet, but they all are inherting from Activity or
ListActivity. In my case the class ContactAdapterView extends the
LinearLayout and hence doesn't work in the same way like in the
example from the API demos (List6.java).

Here's my code:
-----------------------

class ContactAdapterView extends LinearLayout {
        public ContactAdapterView(Context context,
                                                                Contact contact 
) {
            super( context );

            this.setOrientation(HORIZONTAL);

            LinearLayout.LayoutParams stateParams =
                new LinearLayout.LayoutParams(40, 30);

                        ImageView stateControl = new ImageView( context );
                        stateControl.setImageResource( 
contact.getStateResource() );
                        addView( stateControl, stateParams );

                        LinearLayout.LayoutParams nameParams =
                new LinearLayout.LayoutParams(200, 30);
            nameParams.setMargins(1, 1, 1, 1);



            TextView nameControl = new TextView( context );
            nameControl.setGravity(10);
            nameControl.setText( contact.getName() );
            nameControl.setTextSize(14f);
            nameControl.setTextColor(Color.WHITE);


            addView( nameControl, nameParams);
        }


}



public class ContactAdapter extends BaseAdapter {
[...]
--------------------------------

I wanted to use the "setOnClickListener" method of the nameControl
element, but I failed. Does anyone have a solution to realize opening
a list by clicking on the nameControl textview element?

Thanks



On 10 Jul., 17:01, "Mark Murphy" <[EMAIL PROTECTED]> wrote:
> > how would you implement a list containingmultiplecolumnslike in the
> > contacts demo application which contains the names and a star with
> > "mobile" at the right.
> > I want to display my contacts by adding icons behind the names in an
> > additional column.
>
> Generally speaking, you need to provide a more complicated View for each
> row than the traditional TextView.
>
> For simple cases, you may be able to get away with just creating a layout
> XML file for the row (e.g., LinearLayout with an ImageView for your icon
> and a TextView for your name) and supply that resource ID instead of the
> ever-popular android.R.layout.simple_list_item_1 in your Adapter
> constructor.
>
> For more power, subclass your desired Adapter and implement getView(),
> where you can return (or re-populate) Views you create either by manual
> construction or by using ViewInflate on a layout XML file.
>
> Here are a couple of threads on this topic I've contributed to over the
> past few months:
>
> http://groups.google.com/group/android-developers/browse_thread/threa...
>
> http://groups.google.com/group/android-developers/browse_frm/thread/3...
>
> List6.java in the ApiDemos in the SDK is one of the closer examples to
> this, and I'm sure there are any number of tutorials over on anddev.org
> that cover it as well.
>
> And, like I just told Mr. Steele, I'll be writing up all of this over on
> the AndroidGuys blog over the next few weeks.
>
> --
> 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 [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