<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout /* not important */>
<TextView /* not important */ />
<TextView /* not important */ />
<RelativeLayout
/* not important */
android:id="@+id/detailLayout"
android:visibility="gone">
<TextView /* not important */ />
</RelativeLayout>
</RelativeLayout>
private class ItemClickListener implements AdapterView.OnItemClickListener
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
RelativeLayout detailLayout = (RelativeLayout) view.findViewById(R.id.detailLayout);
int detailLayoutVisibility = detailLayout.getVisibility();
if(detailLayoutVisibility == View.GONE)
{
detailLayout.setVisibility(View.VISIBLE);
}
else
{
detailLayout.setVisibility(View.GONE);
}
}
}
首先,当我点击该项目时,事件会触发,detailLayout
会将可见性更改为View.VISIBLE
,但是再次尝试点击它会导致没有事件触发。
答案 0 :(得分:2)
首先,为detailLayout
创建一个全局变量,而不是每次单击时都初始化它。然后,在onCreate
实施detailLayout
之后,this
将点击监听器onClickListener
设置为AdapterView.OnItemClickListener
。
另外,为什么要实施View.OnClickListener
而不是RelativeLayout
?您想要点击detailLayout
非适配器吗?
不要只设置GONE
到detailLayout
的可见性,还要尝试对TextView
的子视图执行相同操作,即设置detailLayout
的可见性在GONE
到
ELASTICSEARCH_URL=http://elasticsearch-logging.kube-system:9200
{"@timestamp":"2016-04-19T02:39:08.559Z","level":"error","message":"Service Unavailable","node_env":"production","error":{"message":"Service Unavailable","name":"Error","stack":"Error: Service Unavailable\n at respond (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/transport.js:235:15)\n at checkRespForFailure (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/transport.js:203:7)\n at HttpConnector.<anonymous> (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/connectors/http.js:156:7)\n at IncomingMessage.bound (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/node_modules/lodash-node/modern/internals/baseBind.js:56:17)\n at IncomingMessage.emit (events.js:117:20)\n at _stream_readable.js:944:16\n at process._tickCallback (node.js:442:13)\n"}}
{"@timestamp":"2016-04-19T02:39:08.652Z","level":"fatal","message":"Service Unavailable","node_env":"production","error":{"message":"Service Unavailable","name":"Error","stack":"Error: Service Unavailable\n at respond (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/transport.js:235:15)\n at checkRespForFailure (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/transport.js:203:7)\n at HttpConnector.<anonymous> (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/connectors/http.js:156:7)\n at IncomingMessage.bound (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/node_modules/lodash-node/modern/internals/baseBind.js:56:17)\n at IncomingMessage.emit (events.js:117:20)\n at _stream_readable.js:944:16\n at process._tickCallback (node.js:442:13)\n"}}
内。
答案 1 :(得分:1)
尝试将detailLayout设置为
android:clickable="false"
android:focusable="false"
另外,你说的东西不重要,很可能非常重要。