Ok it's working - I would like to be too complex :)

Thank you

On Dec 18, 2:26 pm, arnouf <[email protected]> wrote:
> Now it's ok but I don't see my layout :(
>
> As my view was not loaded correctly :(
>
> Thanks MArk for your help (and your book :))
>
> On Dec 18, 2:05 pm, Mark Murphy <[email protected]> wrote:
>
> > arnouf wrote:
> > > Hi all,
>
> > > My code is following
> > > class MyAdapter extends View{
> > >  public MyAdapter(Context context,
> > >                            ContactPerso contact) {
> > >             super( context );
> > >             inflate(context, R.layout.myadaptercontact, null);
>
> > >             
> > > ((TextView)findViewById(R.id.txtViewName)).setText(contact.name);
>
> > >     }
> > > }
> > > myadaptercontaxt is an xml file containing a LinearLayout and 3
> > > textField (including txtViewName)
>
> > > My code crashes when I try to access to txtViewName, as if the layout
> > > was not loaded.
>
> > > What I need to put more after inflate to work with my new view?
>
> > inflate() returns a View. That is the View containing R.id.txtViewName.
>
> > View inflated=inflate(context, R.layout.myadaptercontact, null);
>
> > ((TextView)inflated.findViewById(R.id.txtViewName)).setText(contact.name);
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com
> > _The Busy Coder's Guide to Android Development_ Version 1.9 Published!
--~--~---------~--~----~------------~-------~--~----~
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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to