Ver Mensaje Individual
  #11 (permalink)  
Antiguo 26/06/2014, 06:05
Avatar de ManelGomez
ManelGomez
 
Fecha de Ingreso: diciembre-2007
Ubicación: El Prat de llobregat
Mensajes: 180
Antigüedad: 18 años, 9 meses
Puntos: 2
Respuesta: formatear cantidades en un ListView

Hola:

Ahora no me da ningun error, pero la cadena no la formatea:

Código PHP:
    @Override
    
public View getView(int position, View convertView, ViewGroup parent) {
        
View vi        = convertView;
        
VistaHolder vh = null;
        if (
vi == null) {
            
vi  = minflater.inflate(R.layout.contact_list_row, null);
            
vh = new VistaHolder();
            
vh.name  = (TextView) vi.findViewById(R.id.tv_name);
            
vh.phone = (TextView) vi.findViewById(R.id.tv_phone);
            
vi.setTag(vh);
        }
        
vh = (VistaHolder) vi.getTag();
        
Items contactListItems = mcontactList.get(position);        
        
vh.name.setText(contactListItems.getName());
        
vh.phone.setText(FormatearCadena(contactListItems.getPhone()));
    return 
vi;
    }

    public 
String FormatearCadena(String cadena) {
        
DecimalFormat df = new DecimalFormat("###-###-###-###");
        
String strPhone = df.format(cadena);
        return 
strPhone; 
    } 
Esta porcion de código es de un adaptador personalizado que extiends de un BaseAdapter. Entre los métodos el más importe es el public View getView, es aqui donde intento formatear el dato, en este caso el campo phone definido como un string en la tabla y en la clase.

Tal como decia Jomaruro y Raspeitia voy a mirar lo logcat y el stackoverflow.

un saludo.