在Activity中的代码:
set_reminder_layout = (LinearLayout) date_time_setting.findViewById(R.id.set_reminder_layout);
set_circle_layout = (LinearLayout) date_time_setting.findViewById(R.id.set_circle_layout);
set_reminder_layout.setOnTouchListener(new LayoutClickListener());
set_circle_layout.setOnTouchListener(new LayoutClickListener()); private class LayoutClickListener implements OnTouchListener { @Override
public boolean onTouch(View v, MotionEvent event) {
int id = v.getId();
System.out.println("Asd");
switch(id) {
case R.id.set_circle_layout:
Toast.makeText(MemoryPad.this, "set_circle_layout", Toast.LENGTH_SHORT).show();
break;
case R.id.set_reminder_layout:
Toast.makeText(MemoryPad.this, "set_reminder_layout", Toast.LENGTH_SHORT).show();
break;
}
return false;
}
}
其中一个线性布局对象在date_time_setting.xml中的属性设置,实在不知道怎办,把属性能true的都true了
android:id="@+id/set_reminder_layout"
android:focusable="true"
android:focusableInTouchMode="true"
android:clickable="true"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
main.xml文件中使用了include标签,引用了date_time_setting.xml,两个线性布局对象在date_time_setting.xml文件中,而且这两个线性布局是在date_time_setting.xml中另外的线性布局中,被包了几层,
程序允许的结果是,没有报错,但是程序没有按照监听事件的效果呈现出来。试了setOnClickListener,也没有效果。
我要的效果就是实现这两个布局对象的监听,产生相应的结果即可。请各位路过走过的大虾指导指导。
set_reminder_layout = (LinearLayout) date_time_setting.findViewById(R.id.set_reminder_layout);
set_circle_layout = (LinearLayout) date_time_setting.findViewById(R.id.set_circle_layout);
set_reminder_layout.setOnTouchListener(new LayoutClickListener());
set_circle_layout.setOnTouchListener(new LayoutClickListener()); private class LayoutClickListener implements OnTouchListener { @Override
public boolean onTouch(View v, MotionEvent event) {
int id = v.getId();
System.out.println("Asd");
switch(id) {
case R.id.set_circle_layout:
Toast.makeText(MemoryPad.this, "set_circle_layout", Toast.LENGTH_SHORT).show();
break;
case R.id.set_reminder_layout:
Toast.makeText(MemoryPad.this, "set_reminder_layout", Toast.LENGTH_SHORT).show();
break;
}
return false;
}
}
其中一个线性布局对象在date_time_setting.xml中的属性设置,实在不知道怎办,把属性能true的都true了
android:id="@+id/set_reminder_layout"
android:focusable="true"
android:focusableInTouchMode="true"
android:clickable="true"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
main.xml文件中使用了include标签,引用了date_time_setting.xml,两个线性布局对象在date_time_setting.xml文件中,而且这两个线性布局是在date_time_setting.xml中另外的线性布局中,被包了几层,
程序允许的结果是,没有报错,但是程序没有按照监听事件的效果呈现出来。试了setOnClickListener,也没有效果。
我要的效果就是实现这两个布局对象的监听,产生相应的结果即可。请各位路过走过的大虾指导指导。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<ImageView
android:background="#ffdddddd"
android:layout_width="match_parent"
android:layout_height="1.0px"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
<LinearLayout
android:gravity="center"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:background="#ffdddddd"
android:layout_width="1.0px"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/set_reminder_layout"
android:focusable="true"
android:focusableInTouchMode="true"
android:clickable="true"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
<TextView
android:textSize="14.0sp"
android:gravity="left|center"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="提醒"
android:drawableLeft="@drawable/ic_remind"
android:drawablePadding="2.0dip"
android:clickable="false"
android:focusable="false"/>
<TextView
android:textSize="18.0sp"
android:gravity="left|center"
android:paddingLeft="10.0dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="不提醒"
android:layout_weight="1.0"
android:clickable="false"
android:focusable="false"/>
<TextView
android:gravity="right|center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:drawableRight="@drawable/down_arrow"
android:layout_marginRight="10dp"
android:focusable="false"/>
</LinearLayout>
<ImageView
android:background="#ffdddddd"
android:layout_width="match_parent"
android:layout_height="1.0px"
android:clickable="false" />
<LinearLayout
android:id="@+id/set_circle_layout"
android:focusable="true"
android:focusableInTouchMode="true"
android:clickable="true"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
<TextView
android:textSize="14.0sp"
android:gravity="center"
android:layout_gravity="left|center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="重复"
android:drawableLeft="@drawable/ic_repeat"
android:drawablePadding="2dp"
android:clickable="false" />
<TextView
android:textSize="18.0sp"
android:gravity="left|center"
android:paddingLeft="10.0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="不重复"
android:layout_weight="1.0"
android:clickable="false" />
<TextView
android:gravity="right|center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:drawableRight="@drawable/down_arrow"
android:layout_marginRight="10dp"
android:clickable="false"/>
</LinearLayout>
<ImageView
android:background="#ffdddddd"
android:paddingLeft="40dp"
android:layout_width="match_parent"
android:layout_height="1.0px"
android:clickable="false" />
</LinearLayout>
<ImageView
android:background="#ffdddddd"
android:layout_width="1.0px"
android:layout_height="match_parent"
android:layout_marginRight="20dp"
android:clickable="false" />
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarTrackVertical="@drawable/scrollbar_vertical_track"
android:scrollbarThumbVertical="@drawable/scrollbar_vertical_thumb"
android:layout_weight="1.0"
android:scrollbarSize="12dip">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/et_memory_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:hint="备忘录标题"
android:singleLine="true"
android:maxLength="16"
android:layout_alignParentTop="true" />
<EditText
android:id="@+id/et_memory_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:maxLines="8"
android:maxLength="128"
android:hint="备忘录内容" />
<Button
android:id="@+id/btn_setDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="日期设置"
android:gravity="left|center"
android:layout_margin="5dp"
android:hint="提醒"
android:drawableLeft="@drawable/ic_remind"/>
<Button
android:id="@+id/btn_setCircle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="不重复"
android:hint="重复"
android:gravity="left|center"
android:layout_margin="5dp"
android:drawableLeft="@drawable/ic_repeat"/>
</LinearLayout>
<include layout="@layout/date_time_setting"/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="8.0"
android:layout_alignParentBottom="true">
<Button
android:id="@+id/btn_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:text="保存"
android:layout_margin="5dp"
android:layout_alignParentBottom="true"/>
<Button
android:id="@+id/btn_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:layout_margin="5dp"
android:text="取消"
android:layout_alignParentBottom="true"/>
</LinearLayout>
</LinearLayout>
ScrollView sv;// 成员变量
sv = (ScrollView)this.findViewById(R.id.scrollView);
sv.setOnTouchListener(new ScrollViewOnTouchListener());
private class ScrollViewOnTouchListener implements OnTouchListener {@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_MOVE) return true;
if (event.getAction() == MotionEvent.ACTION_DOWN) return false;
return false;
}
}
ScrollView sv;// 成员变量
sv = (ScrollView)this.findViewById(R.id.scrollView);
sv.setOnTouchListener(new ScrollViewOnTouchListener());
private class ScrollViewOnTouchListener implements OnTouchListener {@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_MOVE) return true;
if (event.getAction() == MotionEvent.ACTION_DOWN) return false;
return false;
}
}