如何简单的clic或long clic whit定制适配器?

时间:2015-11-04 14:59:24

标签: android

我有一个自定义适配器,在我的maiActivity中,我有一个带有自定义适配器的elementosList,我有我的代码:

AdapterView.OnItemClickListener listener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String elementoSeleccionado = parent.getItemAtPosition(position).toString();
            Boolean realizado = getRealizadoPorElemento(elementoSeleccionado);
            if (realizado == true){
                actualizaRealizado(elementoSeleccionado,"N");

          elementosList.getChildAt(position).setBackgroundColor(Color.TRANSPARENT);
            }else if (realizado == false){
                actualizaRealizado(elementoSeleccionado,"S");
                elementosList.getChildAt(position).setBackgroundColor(Color.parseColor("#3DF400"));
            }
        }
    };
    elementosList.setOnItemClickListener(listener);

    //Long clic
    elementosList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            elementoSeleccioando = parent.getItemAtPosition(position).toString();
            return false;
        }
    });

但它没有用。

我需要在我的自定义适配器上实现一些点击?或者这里是错误?

0 个答案:

没有答案