Avoid ListView overlay

2

I have a problem with the% s of% s which is as follows: I work with 2% with% s and I want when I click on one, that the other disappears and that they do not overlap as they have. I just want it when I click and open the first ListView and then sooner if I click to open the second ListView , let the first one close.

The code I am using is this and can also be seen by the following image:

    switch (v.getId()) {
        case R.id.like:

            preecheListLike();

            listaLike.setVisibility(View.VISIBLE);
            listaLike.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                    String nome = listaLike.getItemAtPosition(position).toString();

                    setMarker(latit, longi, nome, true, position);
                    listaLike.setVisibility(View.INVISIBLE);
                    setUpMap();
                }

            });

            break;
        case R.id.dislike:

            preecheListDislike();
            listaDislike.setVisibility(View.VISIBLE);
            //listaLike.setVisibility(View.INVISIBLE);
            listaDislike.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    String nome = listaDislike.getItemAtPosition(position).toString();

                    setMarker(latit, longi, nome, false, position);
                    listaDislike.setVisibility(View.INVISIBLE);
                    setUpMap();
                }
            });
            break;
        case R.id.rota:
            //AQUI ATIVA O BOTAO CALCULAR ROTA
            //showDist.setVisibility(View.VISIBLE);
            calcRout.setVisibility(View.VISIBLE);
            yourDest.setVisibility(View.VISIBLE);

        break;


    }

}

Image illustrating the problem:

    
asked by anonymous 05.02.2015 / 03:34

1 answer

1

In my view they are superimposed because by default when you do not put visibility in layout it becomes VISIBLE .

So I've analyzed your logic and you're only going to change the visibility when passing through switch (v.getId())

Another tip is to use the View.GONE that @Wakim commented, because INVISIBLE only hides the content, but has the space of the view allocated, already GONE will clear and free up the space for another View to use. For more information View

    
09.02.2015 / 21:51