各位大哥,小弟最近遇到一个问题,在做android一个页面的时候,我这样设计的
pubic class EventView extends LinearLayout{
public LinearLayout totalAreaLayout = null;
public ScrollView fatherScrollView = null;
public EventView(Context context) {
super(context);
initial(context);
}
initial(Context context) { totalAreaLayout = new LinearLayout(context);
totalAreaLayout.setGravity(Gravity.VERTICAL);
TextView titleTip = new TextView(context);
titleTip.setText("here is the information:");
totalAreaLayout.addView(titleTip ); fatherScrollView = new ScrollView(context);
fatherScrollView.addView(addContentLinearLayout (context));
totalAreaLayout.addView(fatherScrollView);
addView(totalAreaLayout);
}
LinearLayout addContentLinearLayout (Context context){
LinearLayout sonLinearLayout = new LinearLayout(context);
//some views
return sonLinearLayout ;
}
}
现在我遇到的问题就是,由于里linearLayout里面加载的数据是从网络上动态获取的。所以不能一次加载完,所以我想做到,当ScrollView 的ScrollBar滑动到最底端的时候,获取此时的时间,然后请求数据,move掉当前的数据,加载现在请求的数据。
所以想问问各位大哥,我的ScrollView 布局只是我这个外围的linearLayout布局的一个部分。我应该获取什么事件。并且该怎么样做比较好呢?会不会受到外层布局的影响呢?
分不到,谢谢
万分感谢!
谢谢
pubic class EventView extends LinearLayout{
public LinearLayout totalAreaLayout = null;
public ScrollView fatherScrollView = null;
public EventView(Context context) {
super(context);
initial(context);
}
initial(Context context) { totalAreaLayout = new LinearLayout(context);
totalAreaLayout.setGravity(Gravity.VERTICAL);
TextView titleTip = new TextView(context);
titleTip.setText("here is the information:");
totalAreaLayout.addView(titleTip ); fatherScrollView = new ScrollView(context);
fatherScrollView.addView(addContentLinearLayout (context));
totalAreaLayout.addView(fatherScrollView);
addView(totalAreaLayout);
}
LinearLayout addContentLinearLayout (Context context){
LinearLayout sonLinearLayout = new LinearLayout(context);
//some views
return sonLinearLayout ;
}
}
现在我遇到的问题就是,由于里linearLayout里面加载的数据是从网络上动态获取的。所以不能一次加载完,所以我想做到,当ScrollView 的ScrollBar滑动到最底端的时候,获取此时的时间,然后请求数据,move掉当前的数据,加载现在请求的数据。
所以想问问各位大哥,我的ScrollView 布局只是我这个外围的linearLayout布局的一个部分。我应该获取什么事件。并且该怎么样做比较好呢?会不会受到外层布局的影响呢?
分不到,谢谢
万分感谢!
谢谢
ScrollView.removeAllViews
int visibleItemCount, int totalItemCount) {
lastItem = firstVisibleItem + visibleItemCount - 1;
if (adapter.count == lastItem) {
adapter.count += 10;
adapter.notifyDataSetChanged();
} } public void onScrollStateChanged(AbsListView view, int scrollState) {
// TODO Auto-generated method stub Log.i("onScrollStateChanged", "onScrollStateChanged");
}来自
http://blog.csdn.net/evy_gyw/archive/2011/01/05/6118196.aspx
这个事件有可能被listview截获了,调用listview.setOnScrollListener(),重载OnScrollListener类的onScrollStateChanged()方法来处理