2012-05-01 8 views
-2
アンドロイド

私は配列を取得していますでカスタムレイアウトでTextViewのように合計金額を取得するには...価格数量が、私は価格と数量と合計としてsetttextとしてマルチプレイたい1としてデフォルトとして設定のEditTextある値どのよう

私はどのように私に

を..helpんしてください...このコード

public class CustomAdapter extends BaseAdapter 
{ 
    int x; 
    integer[] a; 
    public static ArrayList<String> arr1=new ArrayList<String>(); 
    public static ArrayList<String> itemprice=new ArrayList<String>(); 
    public static ArrayList<Bitmap> itemimage=new ArrayList<Bitmap>(); 
    public Context Context; 
    private LayoutInflater inflater; 
    String total; 

    HashMap<String, String> map = new HashMap<String, String>(); 
    public CustomAdapter(Context context, ArrayList<String> arr,ArrayList<String>  price,ArrayList<Bitmap> image) 
    { 
     Context=context; 
     inflater=LayoutInflater.from(context); 
     arr1=arr; 
     itemprice=price; 
     itemimage=image; 
     System.out.println(itemprice); 
     System.out.println("arr: " + arr.size()); 


    } 
    public int getCount() 
    { 
     // TODO Auto-generated method stub 
     return arr1.size(); 

    } 

    public Object getItem(int position) 
    { 
     // TODO Auto-generated method stub 
     return arr1.get(position); 
    } 

    public long getItemId(int position) 
    { 
     // TODO Auto-generated method stub 
     return position; 
    } 

    public View getView(int position, View convertView, ViewGroup parent) 
     { 
     System.out.println(arr1.get(position)); 

      final ViewHolder holder; 

      if (convertView == null) 
      { 
       convertView = inflater.inflate(R.layout.selecteditemlistview, null); 
       holder = new ViewHolder(); 

       holder.textViewSelectedText = (TextView)convertView.findViewById(R.id.selectedtext); 
       holder.price=(TextView)convertView.findViewById(R.id.selectitemprice); 
       holder.image=(ImageView)convertView.findViewById(R.id.selectitemimagge); 
       holder.qty=(EditText)convertView.findViewById(R.id.selectqty); 
       holder.total=(TextView)convertView.findViewById(R.id.totalamount); 
       convertView.setTag(holder); 
      } 
      else 
      { 
       holder = (ViewHolder) convertView.getTag(); 
      } 
      String amount=holder.qty.getText().toString(); 


      holder.textViewSelectedText.setText(arr1.get(position)); 
      holder.price.setText(itemprice.get(position)); 
      holder.image.setImageBitmap(itemimage.get(position)); 
      holder.total.setText(); 

      return convertView;  
     } 

     class ViewHolder  
     { 
      TextView textViewSelectedText = null; 
      TextView price=null; 
      ImageView image=null; 
      EditText qty=null; 
      TextView total=null; 
     }  
} 

私のEditTextコード

<EditText 
     android:id="@+id/selectqty" android:maxLength="3" android:text="1" 
     android:layout_width="40dp" 
     android:layout_height="30dp" 
     android:layout_alignParentTop="true" 
     android:layout_marginLeft="36dp" 
     android:layout_toRightOf="@+id/selectitemprice" > 

私は合計として価格と数量のsetTextをマルチプレイしたいを試してみてください

答えて

0
then use someThing like: 

textMessage.addTextChangedListener(new TextWatcher(){ 
public void afterTextChanged(Editable s) { 

price=Integer.parseInt(price[position]); 
int qut=Integer.parseInt(s.getText().toString()); 
int total=(price*qut); 
holder.total.setText(String.valueOf(total)); 
     } 
public void beforeTextChanged(CharSequence s, int start, int count, int after){} 
public void onTextChanged(CharSequence s, int start, int before, int count){} 
    });