mna*_*agy 6 android android-listview android-viewpager
我正在尝试编写一个活动,显示一个viewpager,其中包含一些图像和listview下面的一些数据..但我的问题是我只能在屏幕的最后一部分滚动列表视图我想让viewpager可以滚动listview所以我想把它作为标题..这是我的XMl文件
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<com.devsmart.android.ui.HorizontalListView
android:id="@+id/sectionsList"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:background="@drawable/menu_bg" />
<include layout="@layout/main_screen_components" />
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud)
我在课堂上写这篇文章
@Override
protected void onPostExecute(List<News> result) {
Utils.pagerNews(result);
Utils.listNews(result);
ImagePagerAdapter pAdapter = new ImagePagerAdapter(
appManager.getPagerNews());
pager.setAdapter(pAdapter);
View headerView = getLayoutInflater().inflate(R.layout.main_screen_components , null , false);
NewsListAdapter adapter = new NewsListAdapter(getBaseContext(),
appManager.getListNews());
listView.addHeaderView(headerView);
listView.setAdapter(adapter);
progress.dismiss();
}
Run Code Online (Sandbox Code Playgroud)
当我运行这个代码时,它给了我一个重复的分页器..修复了一个数据和一个空的一个作为我的listview的标题..当我删除其中包括我的寻呼机它崩溃当我尝试设置适配器到寻呼机. . 任何的想法 ?
小智 20
只需设置viewPager的onTouchListener,如下所示:
viewPager.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
PointF downP = new PointF();
PointF curP = new PointF();
int act = event.getAction();
if(act == MotionEvent.ACTION_DOWN || act == MotionEvent.ACTION_MOVE || act == MotionEvent.ACTION_UP){
((ViewGroup) v).requestDisallowInterceptTouchEvent(true);
if (downP.x == curP.x && downP.y == curP.y) {
return false;
}
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5118 次 |
| 最近记录: |