本文整理汇总了Java中android.support.v4.view.ViewPager.setOnTouchListener方法的典型用法代码示例。如果您正苦于以下问题:Java ViewPager.setOnTouchListener方法的具体用法?Java ViewPager.setOnTouchListener怎么用?Java ViewPager.setOnTouchListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.ViewPager
的用法示例。
在下文中一共展示了ViewPager.setOnTouchListener方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_benefits_activity);
viewPager = (ViewPager) findViewById(R.id.userBenefitsPager);
viewPager.setAdapter(new UserBenefitsViewpagerAdapter(getSupportFragmentManager()));
viewPager.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
stop();
return false;
}
});
inkPageIndicator = (InkPageIndicator) findViewById(R.id.indicator);
inkPageIndicator.setViewPager(viewPager);
start();
}
示例2: setViewPager
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
/**
* 设置要播放的ViewPager
*
* @param viewPager
*/
public void setViewPager(ViewPager viewPager)
{
final ViewPager oldView = getViewPager();
if (oldView != viewPager)
{
if (viewPager != null)
{
mViewPager = new WeakReference<>(viewPager);
viewPager.setOnTouchListener(mInternalOnTouchListener);
} else
{
mViewPager = null;
}
}
}
示例3: setView
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
/**
* 设置展示控件
*/
public PagerUtils setView(Context context, ViewPager viewPager, LinearLayout ll_dot, ImageView iv_bg, List<View> views) {
this.viewPager = viewPager;
this.ll_dot = ll_dot;
this.iv_bg = iv_bg;
this.views = views;
this.context = context;
viewPager.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
});
return this;
}
示例4: setVpClick
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
/**
* 设置ViewPager的点击事件
*/
public void setVpClick(final ViewPager vp, final IVpClickListener listener) {
if (vp == null) {
return;
}
vp.setOnTouchListener(new View.OnTouchListener() {
int flagTouch = 0;
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
flagTouch = 0;
break;
case MotionEvent.ACTION_MOVE:
flagTouch = 1;
break;
case MotionEvent.ACTION_UP:
if (flagTouch == 0 && listener != null) {
listener.onClick(vp.getCurrentItem());
}
break;
}
return false;
}
});
}
示例5: onCreateView
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.d("onCreateView " + this);
View rod = inflater.inflate(R.layout.drama_og_bog_frag, container, false);
karruselAdapter = new KarruselAdapter(getChildFragmentManager());
viewPager = (ViewPager) rod.findViewById(R.id.pager);
viewPager.setAdapter(karruselAdapter);
viewPager.getLayoutParams().height = billedeHø; // Viewpageren skal fylde præcist ét billede i højden
karruselIndikator = (CirclePageIndicator)rod.findViewById(R.id.indicator);
karruselIndikator.setViewPager(viewPager);
final float density = getResources().getDisplayMetrics().density;
karruselIndikator.setRadius(5 * density);
karruselIndikator.setPageColor(Color.BLACK);
karruselIndikator.setFillColor(App.color.blå);
karruselIndikator.setStrokeColor(0);
karruselIndikator.setStrokeWidth(0);
App.data.dramaOgBog.observatører.add(this);
run();
viewPager.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction()==MotionEvent.ACTION_DOWN || event.getAction()==MotionEvent.ACTION_UP) {
App.forgrundstråd.removeCallbacks(skiftTilNæsteIKarrusellen);
App.forgrundstråd.postDelayed(skiftTilNæsteIKarrusellen, 10000);
}
return false;
}
});
App.forgrundstråd.postDelayed(skiftTilNæsteIKarrusellen, 10000);
AQuery aq = new AQuery(rod);
listView = (PinnedSectionListView) aq.id(R.id.listView).adapter(listeAdapter).getListView();
listView.setEmptyView(aq.id(R.id.tom).typeface(App.skrift_gibson).getView());
listView.setOnItemClickListener(this);
return rod;
}
示例6: initChild
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
private void initChild() {
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT);
viewPager = new ViewPager(context);
viewPager.setLayoutParams(params);
//viewpager初始化
setScrollTime(Default_scrollTime);
//触摸时停止轮播
viewPager.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
stopAutoPlay();
break;
case MotionEvent.ACTION_UP:
startAutoPlay();
break;
}
return false;
}
});
//指示器初始化
llIndicators = new LinearLayout(context);
LayoutParams layoutParams1 = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
layoutParams1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
switch (indicator_gravity) {
case 1:
layoutParams1.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
break;
case 2:
layoutParams1.addRule(RelativeLayout.CENTER_HORIZONTAL);
break;
case 3:
layoutParams1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
break;
}
llIndicators.setLayoutParams(layoutParams1);
this.addView(viewPager);
this.addView(llIndicators);
}
示例7: BannerComponent
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public BannerComponent(Indicator indicator, ViewPager viewPager, boolean indicatorClickable) {
super(indicator, viewPager, indicatorClickable);
handler = new AutoPlayHandler(Looper.getMainLooper());
viewPager.setOnTouchListener(onTouchListener);
initViewPagerScroll();
}
示例8: initChild
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
private void initChild() {
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT);
viewPager = new ViewPager(context);
viewPager.setLayoutParams(params);
//viewpager初始化
setScrollTime(Default_scrollTime);
//触摸时停止轮播
viewPager.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
handler.removeMessages(0);
break;
case MotionEvent.ACTION_MOVE:
handler.removeMessages(0);
break;
case MotionEvent.ACTION_UP:
handler.sendEmptyMessageDelayed(0, 3000);
break;
}
return false;
}
});
//指示器初始化
llIndicators = new LinearLayout(context);
LayoutParams layoutParams1 = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
layoutParams1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
switch (indicator_gravity) {
case 1:
layoutParams1.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
break;
case 2:
layoutParams1.addRule(RelativeLayout.CENTER_HORIZONTAL);
break;
case 3:
layoutParams1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
break;
}
llIndicators.setLayoutParams(layoutParams1);
this.addView(viewPager);
this.addView(llIndicators);
}