1. <i id='yzhk0'><tr id='yzhk0'><dt id='yzhk0'><q id='yzhk0'><span id='yzhk0'><b id='yzhk0'><form id='yzhk0'><ins id='yzhk0'></ins><ul id='yzhk0'></ul><sub id='yzhk0'></sub></form><legend id='yzhk0'></legend><bdo id='yzhk0'><pre id='yzhk0'><center id='yzhk0'></center></pre></bdo></b><th id='yzhk0'></th></span></q></dt></tr></i><div id='yzhk0'><tfoot id='yzhk0'></tfoot><dl id='yzhk0'><fieldset id='yzhk0'></fieldset></dl></div>
    <legend id='yzhk0'><style id='yzhk0'><dir id='yzhk0'><q id='yzhk0'></q></dir></style></legend>
  2. <small id='yzhk0'></small><noframes id='yzhk0'>

        <bdo id='yzhk0'></bdo><ul id='yzhk0'></ul>
      <tfoot id='yzhk0'></tfoot>
    1. 如何在带有 android 的视图寻呼机页面中使用滑动手势?

      时间:2023-10-04
      • <bdo id='xGGRI'></bdo><ul id='xGGRI'></ul>

        <small id='xGGRI'></small><noframes id='xGGRI'>

        <tfoot id='xGGRI'></tfoot>
          <tbody id='xGGRI'></tbody>
        <i id='xGGRI'><tr id='xGGRI'><dt id='xGGRI'><q id='xGGRI'><span id='xGGRI'><b id='xGGRI'><form id='xGGRI'><ins id='xGGRI'></ins><ul id='xGGRI'></ul><sub id='xGGRI'></sub></form><legend id='xGGRI'></legend><bdo id='xGGRI'><pre id='xGGRI'><center id='xGGRI'></center></pre></bdo></b><th id='xGGRI'></th></span></q></dt></tr></i><div id='xGGRI'><tfoot id='xGGRI'></tfoot><dl id='xGGRI'><fieldset id='xGGRI'></fieldset></dl></div>

          1. <legend id='xGGRI'><style id='xGGRI'><dir id='xGGRI'><q id='xGGRI'></q></dir></style></legend>

                本文介绍了如何在带有 android 的视图寻呼机页面中使用滑动手势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我需要在包含三个页面的应用程序中使用视图寻呼机.

                I need to take a view pager in an application which consist of three pages.

                我是 android view pager 的新手.

                I am new to android view pager.

                我在屏幕的后半部分有一个名为 TestSwipingView 的视图,在屏幕的上半部分有另一个视图.

                I have one view named TestSwipingView in second half of the screen and another view for the top half of the screen.

                如何仅将 TestSwipingView 配置为可滑动?

                How do I configure only TestSwipingView as swipe-able?

                推荐答案

                我就是这样实现的.它也可能给你一些想法.

                This is how I implemented it. It may give you some idea too.

                第 1 步:在我的主要活动中,我制作了页面适配器并在 onCreate() 中调用它.

                Step 1 : In my main activity, I have made my page adapter and called it in onCreate().

                public class SomeActivity extends FragmentActivity {
                
                    WebView mWebView;
                    private boolean mFromDropdown = false;
                
                    @Override
                    protected void onCreate(Bundle savedInstanceState) {
                        super.onCreate(savedInstanceState);
                        requestWindowFeature(Window.FEATURE_NO_TITLE);
                        setContentView(R.layout.tutorial_activity);
                
                        Window window = getWindow();
                        DisplayMetrics metrics = getResources().getDisplayMetrics();
                        window.setGravity(Gravity.CENTER);
                        int width = (int) (metrics.widthPixels * 1);
                        int height = (int) (metrics.heightPixels * .85);
                        window.setLayout(width, height);
                
                        mFromDropdown = getIntent().getBooleanExtra("fromDropdown", false);
                
                        MyPagerAdapter adapter = new MyPagerAdapter();
                        ViewPager myPager = (ViewPager) findViewById(R.id.pager);
                        myPager.setAdapter(adapter);
                        myPager.setCurrentItem(0);
                
                    }
                

                第 2 步:这是我的自定义适配器,用于您的示例:

                Step2: This is my Custom Adapter for your example:

                private class MyPagerAdapter extends PagerAdapter {
                            public int getCount() {
                                return 3;
                            }
                
                            public Object instantiateItem(ViewGroup container, int position) {
                                LayoutInflater inflater = (LayoutInflater) container.getContext()
                                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                
                                // Using different layouts in the view pager instead of images.
                
                                int resId = -1;
                
                                       //Getting my layout's in my adapter. Three layouts defined.
                                switch (position) {
                                case 0:
                                    resId = R.layout.tutorial1;
                                    break;
                                case 1:
                                    resId = R.layout.tutorial2;
                                    break;
                                case 2:
                                    resId = R.layout.tutorial3;
                                    break;
                
                                }
                
                                View view = inflater.inflate(resId, container, false);
                                ((ViewPager) container).addView(view, 0);
                                return view;
                            }
                
                            @Override
                            public void destroyItem(ViewGroup container, int position, Object object) {
                                container.removeView((View) object);
                            }
                
                            @Override
                            public boolean isViewFromObject(View view, Object object) {
                                return view == object;
                            }
                
                        }
                
                    }
                

                第 3 步:我的布局:

                Step 3 : My Layouts:

                主布局:

                <?xml version="1.0" encoding="utf-8"?>
                <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#F3F3F4"
                    android:orientation="vertical" >
                
                    <RelativeLayout
                        android:id="@+id/tutorial_actionbar"
                        android:layout_width="match_parent"
                        android:layout_height="48dp" >
                
                        <TextView
                            android:id="@+id/tutorial_header"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:gravity="center"
                            android:paddingLeft="25dp"
                            android:paddingRight="9dp"
                            android:text="Your Text"
                            android:textColor="#666666"
                            android:textSize="16sp" />
                    </RelativeLayout>
                
                    <android.support.v4.view.ViewPager
                        android:id="@+id/pager"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:paddingLeft="9dp"
                        android:paddingRight="9dp" >
                    </android.support.v4.view.ViewPager>
                
                </LinearLayout>
                

                布局放置在 MainLayout 中的 ViewPager 中:

                Layout to put inside the ViewPager in MainLayout:

                <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/linearLayout"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:background="#F3F3F4"
                    android:orientation="vertical" >
                
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="#F3F3F4"
                        android:orientation="vertical" >
                
                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:orientation="vertical"
                            android:padding="18dp" >
                
                            <TextView
                                android:id="@+id/tutorialText2"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:background="#F3F3F4"
                                android:text="title1_secondscreen"
                                android:textColor="#666666"
                                android:textSize="16sp"
                                android:textStyle="bold" />
                
                            <TextView
                                android:id="@+id/tutorialText3"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:background="#F3F3F4"
                                android:text="header1_secondscreen"
                                android:textColor="#666666"
                                android:textSize="16sp" />
                        </LinearLayout>
                
                        <ImageView
                            android:id="@+id/image2"
                            android:layout_width="match_parent"
                            android:layout_height="0dip"
                            android:layout_weight="0.60"
                            android:scaleType="centerInside"
                            android:src="@drawable/page2" />
                
                        <TextView
                            android:id="@+id/tutorialText4"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:background="#F3F3F4"
                            android:padding="10dp"
                            android:text="footer1_secondscreen"
                            android:textColor="#666666"
                            android:textSize="32sp" />
                    </LinearLayout>
                
                </RelativeLayout>
                

                布局放置在 MainLayout 中的 ViewPager 中:

                Layout to put inside the ViewPager in MainLayout:

                <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/linearLayout"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:background="#F3F3F4"
                    android:orientation="vertical" >
                
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="#F3F3F4"
                        android:orientation="vertical" >
                
                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:orientation="vertical"
                            android:padding="18dp" >
                
                            <TextView
                                android:id="@+id/tutorialText2"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:background="#F3F3F4"
                                android:text="title1_thirdscreen"
                                android:textColor="#666666"
                                android:textSize="16sp"
                                android:textStyle="bold" />
                
                            <TextView
                                android:id="@+id/tutorialText3"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:background="#F3F3F4"
                                android:text="header1_thirdscreen"
                                android:textColor="#666666"
                                android:textSize="16sp" />
                
                            <ImageView
                                android:id="@+id/image1"
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                android:scaleType="centerInside"
                                android:src="@drawable/page3" />
                
                          <!--   <TextView
                                android:id="@+id/tutorialText4"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:background="#F3F3F4"
                                android:text="@string/tutoril_text3"
                                android:textColor="#666666"
                                android:textSize="16sp" /> -->
                        </LinearLayout>
                
                
                    </LinearLayout>
                    <TextView
                                android:id="@+id/tutorialText5"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_alignParentBottom="true"
                                android:layout_centerHorizontal="true"
                                android:background="#F3F3F4"
                                android:gravity="center"
                                android:padding="10dp"
                                android:text="footer1_thirdscreen"
                                android:textColor="#666666"
                                android:textSize="32sp" />
                
                </RelativeLayout>
                

                希望这对你有帮助..:)..祝你好运..:)

                Hope this helps you..:)..Good Luck..:)

                这篇关于如何在带有 android 的视图寻呼机页面中使用滑动手势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何在 Android 中向 ViewPager 添加进度条 下一篇:一侧 ViewPager 仅滑动

                相关文章

                <legend id='AJcTr'><style id='AJcTr'><dir id='AJcTr'><q id='AJcTr'></q></dir></style></legend>
              1. <tfoot id='AJcTr'></tfoot>
              2. <i id='AJcTr'><tr id='AJcTr'><dt id='AJcTr'><q id='AJcTr'><span id='AJcTr'><b id='AJcTr'><form id='AJcTr'><ins id='AJcTr'></ins><ul id='AJcTr'></ul><sub id='AJcTr'></sub></form><legend id='AJcTr'></legend><bdo id='AJcTr'><pre id='AJcTr'><center id='AJcTr'></center></pre></bdo></b><th id='AJcTr'></th></span></q></dt></tr></i><div id='AJcTr'><tfoot id='AJcTr'></tfoot><dl id='AJcTr'><fieldset id='AJcTr'></fieldset></dl></div>

                • <bdo id='AJcTr'></bdo><ul id='AJcTr'></ul>

                <small id='AJcTr'></small><noframes id='AJcTr'>