显示线性布局的水平滚动视图。

发布于 2024-12-02 09:45:15 字数 146 浏览 1 评论 0原文

我想创建带有文本描述和按钮的图像的水平滚动视图。

列表中的每个条目将占据整个屏幕,左侧有一张图片,右侧有一些描述性文本。向左或向右滚动会将整个视图移动一个屏幕并显示下一张图片和文本。

显示此类数据的最佳方式是什么?

谢谢, 中号

I would like to create a horizontally scrolling view of an image with text description and a button.

Each entry in the list will take up the entire screen with a picture on the left and some descriptive text to the right of that. Scrolling left or right will move the entire view one screen along and display the next picture and text.

What is the best way to display such data?

Thanks,
M

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

把梦留给海 2024-12-09 09:45:15

你可能需要查看android的ViewFlipper。

You may need to check out the ViewFlipper of android.

日裸衫吸 2024-12-09 09:45:15

我认为您正在寻找可以水平而不是垂直探索的列表视图。

所以你可以看看 水平列表视图代码 当然你可以使用这种类型的画廊的观点....
希望这可以帮助你...
祝您编码愉快。

I think you are in search of listview which can be explored horizontally rather than vertically.

so you can take a look at horizontal listview code of course you can use gallery for this type of view....
Hope this may help you...
Have a Happy coding.

三寸金莲 2024-12-09 09:45:15

好的,这是一种实现我想做的事情的方法。我最初是从 http://geekyouup.blogspot.com/ 获取的2011/07/viewpager-example-from-paug.html 但我想向滚动列表添加多个textView。

一开始我很难包含多个文本视图
该站点的演示中显示了这一点,但这是因为在 destroyItem 和 initemfromObject 方法中强制转换为 TextView。我将为 sqlite 编写一个 PagerCurrsor 适配器,因此当我让它工作时我会将其发布在这里。

另一件需要注意的事情是,当用户滑动列表时,位置会递增,因此您可以使用它来迭代数组或光标。

希望这对其他开发人员有帮助,并感谢您发布的所有答案。

覆盖方法:

        public Object instantiateItem(View collection, int position) {

            layout = inflater.inflate(R.layout.scrolllayout, null);
            TextView tv = (TextView) layout.findViewById(R.id.textView1);
            tv.setText("1________________>" + position);

            TextView tv2 = (TextView) layout.findViewById(R.id.textView2);
            tv.setText("2________________>" + position);

            ((ViewPager) collection).addView(layout);
            return layout;
        }


            @Override
            public void destroyItem(View collection, int position, Object view) {
                    ((ViewPager) collection).removeView((View)view);
            }



            @Override
            public boolean isViewFromObject(View view, Object object) {


               return view==((View)object);
            }

XML:

  <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:id= "@+id/container" 
   android:layout_width="match_parent"
   android:layout_height="match_parent" android:orientation="vertical">

     <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"        android:text="TextView1"  android:id="@+id/textView1"></TextView>
     <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView2"  android:id="@+id/textView2"></TextView>
   </LinearLayout>

[1]http://geekyouup.blogspot.com/2011/07/viewpager-example-from-paug.html

OK, here is a way to implement what I was looking to do. I initially took this from http://geekyouup.blogspot.com/2011/07/viewpager-example-from-paug.html but I wanted to add more than one textView to the scrolling list.

I was struggling at first to include more than the one text view
which is shown in the demo at this site but it was because of then Casting to TextView in the destroyItem and initemfromObject methods. I'm going to be writing a PagerCurrsor adapter for sqlite so I'll post it here when I get it working.

Another thing to note is that position is incremented as the user swipes through the list so you would use that to iterate through an array or a cursor.

Hope this helps other developers and thanks for all the answers posted.

Overidden methods:

        public Object instantiateItem(View collection, int position) {

            layout = inflater.inflate(R.layout.scrolllayout, null);
            TextView tv = (TextView) layout.findViewById(R.id.textView1);
            tv.setText("1________________>" + position);

            TextView tv2 = (TextView) layout.findViewById(R.id.textView2);
            tv.setText("2________________>" + position);

            ((ViewPager) collection).addView(layout);
            return layout;
        }


            @Override
            public void destroyItem(View collection, int position, Object view) {
                    ((ViewPager) collection).removeView((View)view);
            }



            @Override
            public boolean isViewFromObject(View view, Object object) {


               return view==((View)object);
            }

XML:

  <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:id= "@+id/container" 
   android:layout_width="match_parent"
   android:layout_height="match_parent" android:orientation="vertical">

     <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"        android:text="TextView1"  android:id="@+id/textView1"></TextView>
     <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView2"  android:id="@+id/textView2"></TextView>
   </LinearLayout>

[1]http://geekyouup.blogspot.com/2011/07/viewpager-example-from-paug.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文