2012-01-19 64 views
1

我想把表格佈局列表中的表格佈局我有一個微調不能正確顯示它是在寬度拉伸,看起來不好。我在CustomAdapter的getView()方法延伸BaseAdapterTablelLayout與列表視圖中的微調框的怪異行爲

@Override 
     public View getView(int position, View convertView, ViewGroup parent) { 
      final int pos = position; 
      final ViewHolder fHolder; 
      ViewHolder holder ; 
      View view = null; 

      if(convertView == null) { // InflateViewHelper class is returning 
            // object of View class In InflateViewHelper class 
            //i have written 
           //View v = inflater.inflate(R.layout.table_layout, null); 

       InflateViewHelper inflateView = new InflateViewHelper(inflater, aShoppingItem.get(position), mContext); 
       view = inflateView.createView(); 


       holder = new ViewHolder(); 
       holder.txtUnitPrice = (TextView) view.findViewById(R.id.txtUnitPrice); 
       holder.txtTotalPrice = (TextView) view.findViewById(R.id.txtTotalPrice); 
       holder.spinner = (Spinner) view.findViewById(R.id.spinner); 

       view.setTag(holder); 

      } 
      else { 

       view = convertView; 
       holder = (ViewHolder)convertView.getTag(); 

      } 
fHolder = holder; 
      holder.spinner.setOnItemSelectedListener(
        new OnItemSelectedListener() { 

         @Override 
         public void onItemSelected(AdapterView<?> parent, View view, int iposition, long id) 
         { 

          value = parent.getItemAtPosition(iposition).toString(); 

          if(pos<totalItems.size()) 
           totalItems.set(pos, value); 
          else 
           totalItems.add(pos,value); 



          int number = Integer.parseInt(value); 
          int unit = Integer.parseInt(fHolder.txtUnitPrice.getText().toString()); 
          String total = String.format("%d", unit*number); 
          fHolder.txtTotalPrice.setText(total); 
          String amnt = fHolder.txtTotalPrice.getText().toString(); 
          Log.v("AMOUNT", amnt); 

          if(pos< totalAmount.size()) 
           totalAmount.set(pos, amnt); 
          else 
           totalAmount.add(pos, amnt); 

         } 

         @Override 
         public void onNothingSelected(AdapterView<?> parent) { 
          totalItems.add(pos, value); 
          Log.v("[email protected]@@@", value);   
         } 

      }); 

      int number = Integer.parseInt(value); 
      int unit =   Integer.parseInt(holder.txtUnitPrice.getText().toString()); 
      String total = String.format("%d", unit*number); 
      holder.txtTotalPrice.setText(total); 

      return view; 
     } 

,如果我嘗試用簡單的表格佈局這個代碼能夠正常工作 可以在任何告訴我,我錯了

回答

1

膨脹表格的佈局很長一段時間後,解決了這個問題。 爲了解決這個問題,我使用了9個補丁圖像,並把它作爲微調的背景,我得到了更細的微調。我從this link得到了這個答案