布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_mutil"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_marginTop="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<!-- <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" > -->
<!--
android:drawableRight="@drawable/quesion_checkbox_selector"
android:button="@null"
-->
<CheckBox
android:layout_marginLeft="12dp"
android:layout_marginRight="5dp"
android:layout_marginTop="1dp"
android:id="@+id/cb_qustion_body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:button="@null"
android:checked="false"
android:drawableRight="@drawable/quesion_checkbox_selector"
android:textColor="#696969"
android:textSize="14sp" />
<!-- </LinearLayout> -->
<!-- <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" > -->
<LinearLayout
android:id="@+id/ll_qustion_body_controlpic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:layout_marginLeft="10dp"
android:id="@+id/iv_qustion_body"
android:layout_width="100dp"
android:layout_height="100dp"
android:scaleType="fitXY"
android:src="@drawable/personal_head_icon"
android:visibility="gone" />
<TextView
android:id="@+id/tv_qustion_body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="6dp"
android:layout_marginLeft="10dp"
android:text="上海"
android:textColor="#696969"
android:textSize="14dp" />
</LinearLayout>
<!-- </LinearLayout> -->
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#EFEFEF"
/>
</LinearLayout>
布局预览图:
代码控制(最外层线性布局点击事件):
ll_mutil.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Toast.makeText(ctx, "多选,选中", 0).show();
mutil_click(MutilTpleQuestOption, cb_qustion_body, ll_mutil);
// if (QuestionDetailActivity.submitMap.containsKey(tpleQuestSubject.getSubjectId())) {
// if (!positions.contains(position)) {
positions.add(position);
// }
// }
}
});
出问题代码处:
LinearLayout ll_qustion_body_controlpic=(LinearLayout) view.findViewById(R.id.ll_qustion_body_controlpic);
ImageView iv_qustion_body=(ImageView) view.findViewById(R.id.iv_qustion_body);
TextView tv_qustion_body=(TextView) view.findViewById(R.id.tv_qustion_body);
if (canQuest) {
ll_qustion_body_controlpic.setEnabled(true);
ll_mutil.setEnabled(true);
cb_qustion_body.setEnabled(true);
ll_qustion_body_controlpic.setClickable(true);
ll_mutil.setClickable(true);
cb_qustion_body.setClickable(true);
}else{
ll_qustion_body_controlpic.setEnabled(false);
ll_mutil.setEnabled(false);
cb_qustion_body.setEnabled(false);
ll_qustion_body_controlpic.setClickable(false);
ll_mutil.setClickable(false);
cb_qustion_body.setClickable(false);
}
布局文件层次
下面代码 导致: ll_mutil.setOnClickListener 无法接收到事件的传递
ll_qustion_body_controlpic.setEnabled(true);
ll_qustion_body_controlpic.setClickable(true);
ll_qustion_body_controlpic.setEnabled(false);
ll_qustion_body_controlpic.setClickable(false);