Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在充气布局上创建onClick事件_Java_Android - Fatal编程技术网

Java 在充气布局上创建onClick事件

Java 在充气布局上创建onClick事件,java,android,Java,Android,我有一个地质点,每当它被点击时,一个膨胀的布局就会显示该地质点的详细信息。最初,我在充气布局中有一个按钮,但现在我发现: 在返回视图时,视图被渲染为图像(使用view.draw(Canvas))。因此,是否可以为整个充气布局创建onclick事件。下面显示了充气布局的xml文件: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_cont

我有一个地质点,每当它被点击时,一个膨胀的布局就会显示该地质点的详细信息。最初,我在充气布局中有一个按钮,但现在我发现:

在返回视图时,视图被渲染为图像(使用view.draw(Canvas))。因此,是否可以为整个充气布局创建onclick事件。下面显示了充气布局的xml文件:

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:minWidth="150dp"
android:id="@+id/placeInfo"
>
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/txtName"
    android:textColor="#ff555555"
    android:textSize="14dip"
    android:textStyle="bold"
    android:layout_marginTop="5dip"
    />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/txtHours"
    android:textColor="#ff555555"
    android:textSize="14dip"
    android:layout_marginTop="5dip"
    />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/txtCountry"
    android:textColor="#ff555555"
    android:textSize="14dip"
    android:layout_marginTop="5dip"
    />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/txtAddress"
    android:textColor="#ff555555"
    android:textSize="14dip"
    android:layout_marginTop="5dip"
    />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/txtPostCode"
    android:textColor="#ff555555"
    android:textSize="14dip"
    android:layout_marginTop="5dip"
    />


我现在找到了这个问题的解决方案,因为您不能在膨胀布局中选择特定元素,您必须选择完全膨胀的布局。这是通过以下代码行完成的

googleMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() { 
   @Override 
   public void onInfoWindowClick(Marker marker) { 

   }
});