我有这个ListView
和一个扩展了Adapter
的{{1}}。在
BaseAdapter
我将public View getView(final int position, View view, ViewGroup parent) {...}
附加到clickListener
上,像这样:
view
然后,我有一个用户抱怨说,当他单击元素view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final LinearLayout llMatchInfo = v.findViewById(R.id.matchInfo);
if (llMatchInfo == null) return;
llMatchInfo.setVisibility(llMatchInfo.getVisibility() == View.GONE ? View.VISIBLE : View.GONE);
}
});
时,一秒钟内可见该元素,然后又消失了。
这是llMatchInfo
视图唯一更改其可见性的地方。
有人可以帮我弄清楚为什么会这样吗?
预先感谢
这是ListView中每个项目的外部XML:
matchInfo
以及实际matchInfo的内部XML(我想在其中切换可见性的部分):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingEnd="5dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="10dp"
android:layout_height="fill_parent"
android:id="@+id/live_indicator">
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/match_data"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
...
</LinearLayout>
<include
android:layout_width="fill_parent"
android:layout_height="wrap_content"
layout="@layout/match_info"
android:id="@+id/matchInfo" />
</LinearLayout>
</LinearLayout>