Android Scrollview:如何检测Scrollview的开始和结束
这是我的布局XML。我正在表中动态添加更多行Android Scrollview:如何检测Scrollview的开始和结束,android,scrollview,paging,Android,Scrollview,Paging,这是我的布局XML。我正在表中动态添加更多行 <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:myapp="http://schemas.android.com/apk/res/com.tweets" android:id="@+id/screen"
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.tweets"
android:id="@+id/screen"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#FFFFFF">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/main"
android:background="#FFFFFF">
<TableRow android:id="@+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:id="@+id/TLocView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15px"
android:textStyle="bold"
android:textColor="#000000"
android:text="FatWallet Tweets:">
</TextView>
</TableRow>
</TableLayout>
</ScrollView>
我想用scrollview实现分页。若用户试图向后或向前滚动,那个么我想发出上一页和下一页请求。怎么做?任何暗示都将不胜感激。谢谢 这里有一个肮脏的方法来解决这个问题
tl = (TableLayout) findViewById(R.id.main);
tl.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
int y = v.getHeight();
int y1 = (int) event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
if (y1 + 50 >= y & more) {
//System.out.println("ACTION_DOWN " + bpg);
more();
}
break;
}
case MotionEvent.ACTION_UP: {
if (y1 - 50 <= 100 & bpg > 1) {
//System.out.println("ACTION_UP");
less();
}
break;
}
case MotionEvent.ACTION_MOVE: {
//System.out.println("ACTION_MOVE " + bpg);
if (y1 - 50 <= 100 & bpg > 1) {
//System.out.println("ACTION_UP");
less();
}
break;
}
}
//System.out.println("Test " + y + " " + y1);
return true;
}
});
tl=(TableLayout)findviewbyd(R.id.main);
tl.setOnTouchListener(新的OnTouchListener(){
公共布尔onTouch(视图v,运动事件){
int y=v.getHeight();
inty1=(int)event.getY();
开关(event.getAction()){
case MotionEvent.ACTION\u DOWN:{
如果(y1+50>=y及以上){
//System.out.println(“动作向下”+bpg);
更多();
}
打破
}
case MotionEvent.ACTION\u UP:{
如果(y1-50 1){
//System.out.println(“动作启动”);
减去();
}
打破
}
case MotionEvent.ACTION\u移动:{
//系统输出打印项次(“动作移动”+bpg);
如果(y1-50 1){
//System.out.println(“动作启动”);
减去();
}
打破
}
}
//系统输出打印项次(“测试”+y+“”+y1);
返回true;
}
});
ACTION_DOWN事件正在处理下一页,ACTION_MOVE事件正在处理上一页。我正在检查当前Y是快结束了还是开始了,然后才开始行动。它不是干净的,而是让它工作的一种方法