我试图查看类似的问题,但没有找到任何解决方案或最佳实践。
我的问题如下。
我有自定义视图,例如
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<com.viewpagerindicator.CirclePageIndicator
android:id="@+id/bottom_indicator"
android:padding="10dip"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
这是我的自定义视图的布局(不是最终会有一些区别,只是为了让它更具可读性)。
您可以在此处查看CirclePageIndicator
。它是硬编码的,它将是这种类型的指标
我需要什么?
我正在寻找让用户能够选择我的自定义视图属性的指定值的理想指标的最佳方法,并且在运行时检查用户选择并充气这种类型的指标
我有一些想法如何做到这一点,但不知道什么是更好的性能和干净的代码。
ViewPager
(以及我希望在自定义视图中使用的内容),而不是在运行时只是根据选择创建指标对象并将其添加到视图层次结构中ViewStub
,我还必须指定要充气的所需视图的ID。请以最正确和最优雅的方式帮助解决这个问题。
我将不胜感激任何建议,解释和例子。
提前感谢大家。