Scrolliview

package com.example.scrollview;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.Window;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivity extends Activity {
    private boolean isLoad = false;

private ArrayAdapter<String> adapter;
    private ListView lv;
    String name[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",
            "12" };

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
        lv = (ListView) findViewById(R.id.lv);
        adapter = new ArrayAdapter<String>(MainActivity.this,
                android.R.layout.simple_list_item_1, name);
        lv.setAdapter(adapter);
        lv.setOnScrollListener(new OnScrollListener() {

public void onScrollStateChanged(AbsListView view, int scrollState) {

if (isLoad
                        && scrollState == OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
                    Toast.makeText(getApplicationContext(), "11111111", 0)
                            .show();
                    lv.getParent().getParent()
                            .requestDisallowInterceptTouchEvent(false);

}
            }

@Override
            public void onScroll(AbsListView view, int firstVisibleItem,
                    int visibleItemCount, int totalItemCount) {

isLoad = ((firstVisibleItem + visibleItemCount) == totalItemCount);

}
        });
    }

}

package com.example.scrollview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ListView;

public class Mylistview extends ListView {

public Mylistview(Context context, AttributeSet attrs) {
        super(context, attrs);

}

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

// 对height重新赋值7
        heightMeasureSpec = MeasureSpec.makeMeasureSpec(
        /* Integer.MAX_VALUE >> */300, MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

public boolean dispatchTouchEvent(MotionEvent ev) {

getParent().requestDisallowInterceptTouchEvent(true);
        return super.dispatchTouchEvent(ev);
    }

}

package com.example.scrollview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ScrollView;

public class MyScrollView extends ScrollView {

public MyScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
        
        
    }

}

上一篇:jQuery运行方式818


下一篇:laravel application 容器app