Java 使用数组列表适配器设置android listview的样式
我已经编写了下面显示的一些数组创建列表的代码! 代码运行正常,输出符合预期 具有相同问题的人的更新: MainActivity.java activity_main.xml listview.xml 我想要完成什么 将每个列表项中文本的颜色和字体更改为不同的颜色和字体..并在点击它们时执行一些任务 也可以在同一个listview中获得另一个listview吗 如果我点击一个列表项,它会再次显示一个列表类型的子列表,在同一个活动或屏幕上有不同的列表项。点击子列表项可以执行一些操作 详细的答案非常感谢,因为我是android开发新手。。Java 使用数组列表适配器设置android listview的样式,java,android,listview,styles,Java,Android,Listview,Styles,我已经编写了下面显示的一些数组创建列表的代码! 代码运行正常,输出符合预期 具有相同问题的人的更新: MainActivity.java activity_main.xml listview.xml 我想要完成什么 将每个列表项中文本的颜色和字体更改为不同的颜色和字体..并在点击它们时执行一些任务 也可以在同一个listview中获得另一个listview吗 如果我点击一个列表项,它会再次显示一个列表类型的子列表,在同一个活动或屏幕上有不同的列表项。点击子列表项可以执行一些操作 详细的答案非常感
谢谢 您需要查看一个定制的ArrayAdapter,如图所示 这将解决第一个和第三个问题。至于第二个,ListView的默认实现不可能实现,但是有一些库允许您创建下拉列表项
1.change color and font of the text in each list item to a different one..and do some task on
tapping on them...
创建自定义适配器,覆盖该适配器的getVIew并创建
更改其中的颜色和文本。
覆盖ListView的McClick。完成点击事件
对于列表项。
现在
更多信息,请查看链接
信息
对于第一个问题,您可以使用12345的答案 第二个问题:你必须使用 有关更多详细信息,请参阅: 第三个问题不是建设性的,非常模糊。请编辑问题并详细解释 使用它 在列表中包含列表是不可能的。使用 看看
你说的是定制的ListView吗?是的!一个可以轻松定制并与ArrayAdapter配合使用的listView看看我的答案。如果>>>自定义listView。?是一个链接它断了!在评论中。?不,这不是一个链接,我在下面的回答中为它提供了一个链接。你能提供一个简单的示例代码,或者让我访问包含该示例的网站吗!谷歌搜索并没有为我提供可以理解的东西
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<ListView
android:id="@+id/listView1"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:padding="22dp"
android:gravity="center_horizontal"
/>
1.change color and font of the text in each list item to a different one..and do some task on
tapping on them...
2. also is it possible to get another listview inside the same listview eg. if I click on a
list item it again shows me a list (kind of a sub list) with different list items on that
same activity(or screen).and some action could be done on tapping the sub list items.
3. what are my other list styling options..