Diseñar vistas de Android a partir de XML existente usando un inflador

How should I write my XML file, where should I put it and how should I reference them in the activity?

Esto es lo que conseguí:

myView = getLayoutInflater().inflate(R.???someplace???.???somename???, null);

What should be set instead of someplace y somename ? And if I have created this XML with 2 elements (a TextView y LinearLayout, for example) how can I make myView look like the first element and mySecondView look like the other element in that XML?

After solving it, will mainView.addView(myView) para lograr myView appear in the Activity with the pre-defined style?

I've been reading that it is the best solution for defining style in a separate XML file and then applying it to a View created programmatically.

preguntado el 22 de septiembre de 13 a las 22:09

1 Respuestas

See this sample code for inflating view..

{
View headerView = inflater.inflate(R.layout.icms_article_detail_header, null, false);
articleDetailDataProvider = new IcmsArticleDetailDataProvider(mContext);
txtPageIndicator=(IjoomerTextView)headerView.findViewById(R.id.icmsTxtIndicator);
imgFavorite = (ImageView) headerView.findViewById(R.id.icmsImageFavorite);
imgShare = (ImageView) headerView.findViewById(R.id.icmsImageShare);
list.addHeaderView(headerView);
}

Respondido el 23 de Septiembre de 13 a las 06:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.