好的,我这几天一直在寻找。我一直在寻找人们为实现这一目标而制作的自定义类。特别是Jeff Sharkey 的课程和 Commonsware 课程。
我注意到 Jeff Sharkey 在 2008 年发表了这篇文章。现在那是不久前的事了。谷歌是否集成了一种无需使用自定义类的方法?我真的很想不必使用自定义类,只需坚持使用 java/android sdks
我有一个 twolinelistview.xml,其中有 2 个文本视图。我用常规数据填充底部文本,用标题数据填充顶部文本。空的标题项目不会给我带来任何问题。
public static class ViewHolder {
TextView toptext;
TextView bottomtext;
}
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/lv_topText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@drawable/ltGrey"
android:background="@drawable/semiTransparentDrk"
android:textSize="24sp"
android:typeface="sans"
android:textStyle="bold"
android:ellipsize="end"
android:scrollHorizontally="true"
android:padding="10sp"/>
<TextView
android:id="@+id/lv_bottomText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@drawable/ltGrey"
android:background="@drawable/semiTransparentDrk"
android:textSize="18sp"
android:typeface="sans"
android:textStyle="bold"
android:ellipsize="end"
android:scrollHorizontally="true"
/>
</LinearLayout>
不。Google 提供的 SDK 包含具有足够可扩展性的基本组件,以允许开发人员利用现有的工作来创建自己的组件,而无需做大部分困难的事情。
像列表头这样的东西也不是那么难,谷歌真的不需要将它添加到 SDK 中。
如果您想要做的是避免每次使用项目时都重新制作组件,那么请在 Android 库项目中设置您喜欢的类。还有一些库包含具有额外功能的组件,例如Green Droid等。