thanks but i didn't get your point. here is a piece of my code: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_devis); mainListView = (ListView) findViewById( R.id.mainListView ); mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick( AdapterView<?> parent, View item, int position, long id) { Produit Produit = listAdapter.getItem( position ); Produit.toggleChecked(); ProduitViewHolder viewHolder = (ProduitViewHolder) item.getTag(); viewHolder.getCheckBox().setChecked( Produit.isChecked() ); } }); Produits = (Produit[]) getLastNonConfigurationInstance() ; if ( Produits == null ) { Produits = new Produit[] { new Produit("Produit 1",2), new Produit("Venus",4), new Produit("Earth", 3), new Produit("Produit 1"), new Produit("Produit 13",7), new Produit("Saturn"), new Produit("Produit 1"), new Produit("Neptune"), new Produit("Ceres"), new Produit("Pluto"), new Produit("Haumea"), new Produit("Makemake"), new Produit("Eris") }; } ArrayList<Produit> ProduitList = new ArrayList<Produit>(); ProduitList.addAll( Arrays.asList(Produits) ); // Set our custom array adapter as the ListView's adapter. listAdapter = new ProduitArrayAdapter(this, ProduitList); mainListView.setAdapter( listAdapter ); } ..... private static class ProduitArrayAdapter extends ArrayAdapter<Produit> { int somme=0; int rt ; private LayoutInflater inflater; public ProduitArrayAdapter( Context context, List<Produit> ProduitList ) { super( context, R.layout.row_devis, R.id.rowTextView, ProduitList ); inflater = LayoutInflater.from(context) ; } public View getView(int position, View convertView, ViewGroup parent) { Produit Produit = (Produit) this.getItem( position ); CheckBox checkBox ; TextView textView ; final TextView textViewb ; final EditText editText; if ( convertView == null ) { convertView = inflater.inflate(R.layout.simplerow, null); textView = (TextView) convertView.findViewById( R.id.rowTextView ); checkBox = (CheckBox) convertView.findViewById( R.id.CheckBox01 ); textViewb = (TextView) convertView.findViewById( R.id.rowextViewB ); editText =(EditText)convertView.findViewById(R.id.rowextViewA); convertView.setTag( new ProduitViewHolder(textView,checkBox) ); checkBox.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { CheckBox cb = (CheckBox) v ; Produit Produit = (Produit) cb.getTag(); String nn= Produit.getName(); int prix= Produit.getPu(); if (editText.getText().toString().length()==0) { t2="0"; Log.i("t2", ""+t2); } else {t2=editText.getText().toString(); Log.i("t2", ""+t2); } int qte = Integer.parseInt(t2); int tot = prix*qte; textViewb.setText(""+tot); rt= Integer.parseInt(textViewb.getText().toString()); String np=nn+"-->"+qte+"\n"; setGlob2(np); Log.i("set global",""+setGlob2(nn)); setTotal(tot); Produit.setChecked( cb.isChecked()); prod+=np; setAllprod(prod); Log.i("log",""+prod); somme +=tot; Log.i("log tout",""+somme); } }); } else { ProduitViewHolder viewHolder = (ProduitViewHolder) convertView.getTag(); checkBox = viewHolder.getCheckBox() ; textView = viewHolder.getTextView() ; textViewb= viewHolder.getTextView() ; } checkBox.setTag( Produit ); checkBox.setChecked( Produit.isChecked() ); textView.setText( Produit.getName()+" "+Produit.getPu()); return convertView; } } and this is the simplerow layout: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/ android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/rowTextView" android:layout_width="130dp" android:layout_height="wrap_content" android:paddingLeft="50dp" android:paddingTop="45dp" android:gravity="center_vertical" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:textSize="16sp" > </TextView> <EditText android:id="@+id/rowextViewA" android:layout_marginLeft="150dp" android:layout_width="60dp" android:layout_height="wrap_content" android:numeric="integer" android:textSize="16sp" > </EditText> <TextView android:id="@+id/rowextViewB" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="45dp" android:paddingLeft="260dp" android:gravity="center_vertical" android:layout_centerVertical="true" android:textSize="16sp" > </TextView> <CheckBox android:id="@+id/CheckBox01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dp" android:layout_alignParentRight="false" android:layout_marginRight="6sp" android:focusable="false"> </CheckBox> </RelativeLayout> -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en