我想在OnItemClickListener上显示/隐藏布局。现在我点击它显示布局的项目之后我点击另一个项目前一个是隐藏新的一个是可见的。我想要点击相同的项目可见一个应该是隐藏它。谢谢。
private View previousItem;
movie_gridview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view,
int position, long arg3) {
// TODO Auto-generated method stub
if (previousItem != null) {
LinearLayout buy_dvd_or_movie_layout = (LinearLayout) previousItem
.findViewById(R.id.buy_dvd_or_movie_layout);
buy_dvd_or_movie_layout.startAnimation(slideUp);
buy_dvd_or_movie_layout.setVisibility(View.GONE);
}
LinearLayout buy_dvd_or_movie_layout = (LinearLayout) view
.findViewById(R.id.buy_dvd_or_movie_layout);
buy_dvd_or_movie_layout.setVisibility(View.VISIBLE);
previousItem = view;
}
});