本文介绍了CircularpageIndicator和viewpager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有没有circularpageindicator和查看传呼机的例子或任何现有的库就像我在图片附上。

Do we have any circularpageindicator and view pager example or any existing library like I have attached in image.

推荐答案

让我们在数组中的值/ arrays.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <!-- ... -->

    <!-- Pager position (5 pages) -->
        <string-array name="positions" translatable="false">
            <item>\u25cf \u25cb \u25cb \u25cb \u25cb</item>
            <item>\u25cb \u25cf \u25cb \u25cb \u25cb</item>
            <item>\u25cb \u25cb \u25cf \u25cb \u25cb</item>
            <item>\u25cb \u25cb \u25cb \u25cf \u25cb</item>
            <item>\u25cb \u25cb \u25cb \u25cb \u25cf</item>
        </string-array>

    <!-- ... -->

</resources>

在这里,&LT;! - ... - &GT; 意味着你可能有一些其他的阵列

Here , <!-- ... -- > means you may have some other arrays.

现在,如何在code设置这个值?

Now, how to set this values in code?

// Declare the array (5 positions)
private static String positions[] = new String[5];
// Fill it by getting it from the resource array we prepared earlier
positions = getResources().getStringArray(R.array.positions);

// Prepare an index
private static int pIndex = 0;
//Set it's value in code (here it's fixed, but normally it's a counter)
// pInxex range: 0,..., 4
pIndex = 3;

// Find the position holder View
final TextView txtPosition = (TextView) v.findViewById(R.id.txtPosition);
// Set its value
txtPosition.setText(positions[pIndex]);

结果(pIndex = 3)

Result (pIndex = 3)

这篇关于CircularpageIndicator和viewpager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-10 20:54