你好我想让我的布局可点击我设置android:clickable =“true”...但是在java代码中应该调用一个新的意图......我该怎么办? 这里的XMLcode
<LinearLayout android:layout_height="wrap_content" android:id="@+id/LinearLayout01" android:layout_marginTop="15dp" android:layout_width="match_parent" android:clickable="true">
<TextView android:textColor="#424243" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Visibilità Personalizzata" android:layout_width="wrap_content" android:id="@+id/TextView01" android:layout_gravity="bottom"></TextView>
<ImageView android:id="@+id/freccetta" android:src="@drawable/freccetta" android:layout_marginLeft="30dp" android:layout_height="30dip" android:layout_width="30dip" android:layout_gravity="bottom"></ImageView>
</LinearLayout>
<TextView android:textColor="#424243" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Imposta per quanto tempo vuoi vedere gli amici che si sono disconnessi" android:layout_width="wrap_content" android:id="@+id/textView3" android:layout_marginLeft="20dp" android:clickable="true"></TextView>
答案 0 :(得分:5)
您可以在其上添加OnClickListener:
//onCreate
LinearLayout layout = (LinearLayout) findViewById(R.id.LinearLayout01);
layout.setOnClickListener(yourOnClickListener);
应该有效;)