刷新ListView按下选项DialogFragment

时间:2015-10-10 10:16:10

标签: android listview android-listview pull-to-refresh

我有一个listview,点击一个元素显示一个带有几个选项的DialogFragmen,带有用户的选项将显示在listview TextView的项目中,我在执行时遇到以下错误:

NetPacket::IP

输入我认为重要的代码,如果您还需要其他任何内容来编辑问题:)

这是mi DialogFragment:

Activity app.gepv.Inventario has leaked IntentReceiver com.immersion.android.haptics.HapticFeedbackManager$HapticFeedbackBroadcastReceiver@426e94b8 that was originally registered here. Are you missing a call to unregisterReceiver()?

到目前为止,一切运行良好,因为我查看了Log.i

这是函数ActualizarDisplay():

final String[] items= equiDisp.toArray(new String[equiDisp.size()]);

            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

            builder.setTitle("Asigne equipo/equipos:")
                    .setOnKeyListener(new Dialog.OnKeyListener(){
                         public boolean onKey(DialogInterface arg0, int keyCode,KeyEvent event) {
                                // TODO Auto-generated method stub
                                if (keyCode == KeyEvent.KEYCODE_BACK) 
                                {
                                    finish();
                                    //dialog.dismiss();
                                    actualizarDisplay();
                                }
                                return true;
                            }
                    })

                    .setMultiChoiceItems(items, null, new DialogInterface.OnMultiChoiceClickListener() {
                        public void onClick(DialogInterface dialog, int item, boolean isChecked) {
                            Log.i("Dialogos", "Opción elegida: " + items[item]);
                            if(isChecked)
                            {
                                marcado.add(items[item]);
Log.i("Dialogos", "Marcado: " + items[item]);
                                obras.get(pulsado).equiA.add(Integer.parseInt(items[item]));
for( int k=0; k< obras.get(pulsado).equiA.size(); k++)
{
Log.i("Dialogos", "Equipos: " + obras.get(pulsado).equiA.get(k) );
}

                            }                   
                        }
                    });

这是我对listview的自定义dataApdapter:

public void actualizarDisplay()
{
    adapter = new ObrasAdapter(this, obras);

    lvObras = (ListView) findViewById(R.id.lvItems);
    lvObras.setAdapter(adapter);
    lvObras.setOnItemClickListener(this);
}

}

任何人都可以帮助我吗? 我想我必须做一些事情:

public class ObrasAdapter extends ArrayAdapter<Obra> {
private Context context;
private ArrayList<Obra> datos;

public ObrasAdapter(Context context, ArrayList<Obra> datos) {
    super(context, R.layout.listview_item, datos);
    this.context = context;
    this.datos = datos;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View item = convertView;
    ObrasHolder holder;

    if (item == null) {
        item = LayoutInflater.from(context).inflate(R.layout.listview_item,
                null);
        holder = new ObrasHolder();
        holder.foto = (ImageView) item.findViewById(R.id.imgAnimal);
        holder.num = (TextView) item.findViewById(R.id.numC);
        holder.iden = (TextView) item.findViewById(R.id.idenC);
        holder.ubi = (TextView) item.findViewById(R.id.ubiC);
        holder.hombres = (TextView) item.findViewById(R.id.homC);
        holder.material = (TextView) item.findViewById(R.id.matC);
        holder.eq1 = (TextView) item.findViewById(R.id.eq1);
        holder.eq2 = (TextView) item.findViewById(R.id.eq2);
        holder.eq3 = (TextView) item.findViewById(R.id.eq3);
        holder.eq4 = (TextView) item.findViewById(R.id.eq4);
        holder.fondo = (RelativeLayout) item.findViewById(R.id.fondobra);

        item.setTag(holder);
    }
    holder = (ObrasHolder) item.getTag();

    holder.foto.setImageResource(datos.get(position).getDrawableImageID());

    if(datos.get(position).getPrioridad()==1)
    {
        holder.num.setTextColor(Color.RED);
        holder.iden.setTextColor(Color.RED);
        holder.ubi.setTextColor(Color.RED);
        holder.hombres.setTextColor(Color.RED);
        holder.material.setTextColor(Color.RED);
        holder.eq1.setTextColor(Color.RED);
        holder.eq2.setTextColor(Color.RED);
        holder.eq3.setTextColor(Color.RED);
        holder.eq4.setTextColor(Color.RED);
    }

    if(datos.get(position).getPrioridad()==2)
    {
        holder.num.setTextColor(Color.parseColor("#FF8000"));
        holder.iden.setTextColor(Color.parseColor("#FF8000"));
        holder.ubi.setTextColor(Color.parseColor("#FF8000"));
        holder.hombres.setTextColor(Color.parseColor("#FF8000"));
        holder.material.setTextColor(Color.parseColor("#FF8000"));  
        holder.eq1.setTextColor(Color.parseColor("#FF8000"));   
        holder.eq2.setTextColor(Color.parseColor("#FF8000"));   
        holder.eq3.setTextColor(Color.parseColor("#FF8000"));   
        holder.eq4.setTextColor(Color.parseColor("#FF8000"));   
    }

    if(datos.get(position).getPrioridad()==3)
    {
        holder.num.setTextColor(Color.GREEN);
        holder.iden.setTextColor(Color.GREEN);
        holder.ubi.setTextColor(Color.GREEN);
        holder.hombres.setTextColor(Color.GREEN);
        holder.material.setTextColor(Color.GREEN);
        holder.eq1.setTextColor(Color.GREEN);
        holder.eq2.setTextColor(Color.GREEN);
        holder.eq3.setTextColor(Color.GREEN);
        holder.eq4.setTextColor(Color.GREEN);
    }

    holder.num.setText(datos.get(position).getNum());
    holder.iden.setText(datos.get(position).getIden());
    holder.ubi.setText(datos.get(position).getUb());
    holder.hombres.setText(datos.get(position).getHom());
    holder.material.setText(datos.get(position).getMat());

    if(datos.get(position).getEstado()==1)
    {
        holder.fondo.setBackgroundColor(Color.GREEN);
        holder.num.setTextColor(Color.WHITE);
        holder.iden.setTextColor(Color.WHITE);
        holder.ubi.setTextColor(Color.WHITE);
        holder.hombres.setTextColor(Color.WHITE);
        holder.material.setTextColor(Color.WHITE);
        holder.eq1.setTextColor(Color.WHITE);
        holder.eq1.setTextColor(Color.WHITE);
        holder.eq1.setTextColor(Color.WHITE);
        holder.eq1.setTextColor(Color.WHITE);
    }

    if(! datos.get(position).equiA.isEmpty())
    {
        for(int i=0; i<datos.get(position).equiA.size();i++)
        {
            if(i == 0)
            {
                holder.eq1.setText(String.valueOf(datos.get(position).equiA.get(i)));
            }

            if(i == 1)
                holder.eq2.setText(String.valueOf(datos.get(position).equiA.get(i)));
            if(i == 2)
                holder.eq3.setText(String.valueOf(datos.get(position).equiA.get(i)));
            if(i == 3)
                holder.eq4.setText(String.valueOf(datos.get(position).equiA.get(i)));                   
        }
    }
    else
    {
        holder.eq1.setVisibility(View.INVISIBLE);
        holder.eq2.setVisibility(View.INVISIBLE);
        holder.eq3.setVisibility(View.INVISIBLE);
        holder.eq4.setVisibility(View.INVISIBLE);
    }
    return item;
}

0 个答案:

没有答案