2
I have a problem with ListView
I work with 2 ListView
And I want that when I click one, that the other disappears and that they don’t overlap as they have been. I just want when I click and open the first ListView
and then right before if I click to open the second ListView
, that the first one closes.
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:
Welcome to the Stackoverflow! It is not very clear your doubt, especially at this point: "[...] I want when I click on one other sum and not be superimposed as it has been [...]". We don’t know your application Alezinha, it’s important that you give more details about what’s going on (and if possible what you’ve already tried). It might help to post an image illustrating what you meant by this "overlap". See how ask a good question.
– Renan Gomes
Thanks for the tips, I did a print to illustrate the "problem"
– Alexandra Silva
IMAGE TO ILLUSTRATE THE PROBLEM: http://i58.tinypic.com/105t7jd.jpg
– Alexandra Silva
You left commented the line that hides Listview, is it not working? You even tried to change the visibility with the flag
View.GONE
?– Wakim
Wakim, if I do not comment any listview opens, however if I comment, it looks like in the image I left a link up there. I just wanted to fix it so when someone click on a listview.
– Alexandra Silva
Strange because they are different lists... Do
listaLikes.setVisibility(View.VISIBLE);
andlistaDislikes.setVisibility(View.VISIBLE);
should work. Because you are changing the visibility of different lists. You can tell if the two references do not point to the same object?– Wakim
I just checked and the two lists do not point to the same object. :/
– Alexandra Silva
Could you put the layout? If you are using the
FrameLayout
I think I had problems with visibility. But in the case I used some animations, which caused the problem, and aclearAnimation
ended up solving the visibility problem.– Wakim
I managed to solve it in a kind of rough way, with only one boolean variable :)
– Alexandra Silva
@Alezinha, please, post your solution.
– Luídne