我正在设计一个包含一些滑动部分的屏幕.我有一个屏幕与mapview,listview和一些文本.我的Mapview是滑动的主要部分,如果我在左侧滑动,则会显示联系人,如果我向右滑动,则会显示地址.
这是我的形象.我显示圆滑的部分,我需要刷.
我如何在我的应用程序中实现这个功能.我经历了 one tutorial,但并没有帮助我.本教程教会如何滑动全屏,但我需要刷一些屏幕的一部分.
可能吗.给我一些参考或暗示.我不明白viewPager.
这是我的形象.我显示圆滑的部分,我需要刷.
我如何在我的应用程序中实现这个功能.我经历了 one tutorial,但并没有帮助我.本教程教会如何滑动全屏,但我需要刷一些屏幕的一部分.
可能吗.给我一些参考或暗示.我不明白viewPager.
解决方法
最后,我得到了一个回答来刷卡屏幕的一些部分.
在onCreate()中,您需要添加以下行
在onCreate()中,您需要添加以下行
MyPagerAdapter adapter = new MyPagerAdapter();
myPager = (ViewPager) findViewById(R.id.myfivepanelpager);
myPager.setAdapter(adapter);
myPager.setCurrentItem(3);
我在我的类中扩展了PagerAdapter类.
private class MyPagerAdapter extends PagerAdapter {
public int getCount() {
return 3;
}
public Object instantiateItem(View collection,int position) {
LayoutInflater inflater = (LayoutInflater) collection.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
int resId = 0;
switch (position) {
case 0:
resId = showHotelContact();
break;
case 1:
resId = showHotelAddress();
break;
case 2:
resId = showHotelMap();
break;
}
View view = inflater.inflate(resId,null);
((ViewPager) collection).addView(view,0);
return view;
}
}
public int showHotelMap()
{
int resId;
resId = R.layout.hotelmap;
return resId;
}
public int showHotelAddress()
{
int resId;
resId = R.layout.hoteladdress;
return resId;
}
public int showHotelContact()
{
int resId;
resId = R.layout.hotelcontact;
return resId;
}
这是我的xml文件
?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="fill_parent"> <android.support.v4.view.ViewPager android:id="@+id/myfivepanelpager" android:layout_width="wrap_content" android:layout_height="186dp" android:fadingEdge="vertical" /> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hotelName" /> </LinearLayout>