0
J'ai 10 besoins graphiques à afficher dans mon ListViewandroid utilisation propre image dans ListView
et je crée une classe comme cette
public class LayoutAdapterObj {
public String addString;
public ImageView leftImage;
public String backgroundImageName;
public LayoutAdapterObj(String addString,ImageView leftImageName,String backgroundImageName){
this.addString = addString;
this.leftImage = leftImageName;
this.backgroundImageName = backgroundImageName;
}
et quand je crée un objet LayoutAdaptor
je ce
aArray.add(new LayoutAdapterObj("1",new ImageView(null, null, R.drawable.frame1),"R.drawable.layout"));
aArray.add(new LayoutAdapterObj("2",new ImageView(null, null, R.drawable.frame2),"R.drawable.layout"));
LayoutListAdapter m_adapter;
m_adapter = new LayoutListAdapter(this, R.layout.topbarlayout, aArray);
après que .... dans ma classe d'adaptateur, je le fais
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.layout1, null);
}
LayoutAdapterObj o = items.get(position);
if (o != null) {
TextView addText = (TextView) v.findViewById(R.id.addtext);
ImageView leftImage=(ImageView)v.findViewById(R.id.layoutframe);
if(!o.backgroundImageName.equals(""))
{
}
if(addText!=null)
{
addText.setText(o.addString);
}
le mauvais message est comme ce
java.lang.IllegalStateException: Could not execute method of the activity
if(leftImage != null)
{
leftImage= o.leftImage;
}
semble que vous ne savez pas comment utiliser "modèle de support" ... si convertView! = Null, vous ne configurez pas les vues avec des valeurs ... – Selvin
merci.en fait je sais cela.mais je suis confus ici à cause de Je suis confronté à ce problème. Maintenant, j'ai résolu le problème. –