Android 如何制作文本视图列表?
基本上,以下是我想要实现的目标: 我不希望大纲对用户可见,它只是给你一个想法,我想做什么。每当从GUI底部的edittext按钮组合添加新目标时,我希望新的文本视图在彼此下面占据位置 我知道如何保存数据-SQLite。但我不知道如何使新的文本视图位于最后一个文本视图的底部,如果屏幕上没有更多的空间,我希望文本视图部分可以滚动 我不知道我需要用什么来完成这个 提前谢谢 创建两个xml文件。 一个由列表视图组成的视图Android 如何制作文本视图列表?,android,android-listview,textview,Android,Android Listview,Textview,基本上,以下是我想要实现的目标: 我不希望大纲对用户可见,它只是给你一个想法,我想做什么。每当从GUI底部的edittext按钮组合添加新目标时,我希望新的文本视图在彼此下面占据位置 我知道如何保存数据-SQLite。但我不知道如何使新的文本视图位于最后一个文本视图的底部,如果屏幕上没有更多的空间,我希望文本视图部分可以滚动 我不知道我需要用什么来完成这个 提前谢谢 创建两个xml文件。 一个由列表视图组成的视图 <?xml version="1.0" encodin
<?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"
android:orientation="vertical"
android:background="@drawable/bkgrnd_320x285">
<ListView
android:id="@+id/List1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="#000000"
android:dividerHeight="1dp"
android:fastScrollEnabled="true"/>
</LinearLayout>
另一个xml仅用于textView,例如row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Display Name"
android:textSize="20dp"
android:layout_marginTop="20dp" />
</LinearLayout>
然后在主活动中,您需要引用两个xml文件,如下所示
ListView ll=(ListView)findViewById(R.id.List1)
ArrayAdapter ArrayAdapter=新的ArrayAdapter(这是,R.layout.row,R.id.textView2,arraylist,您希望显示)
ll.设置适配器(阵列适配器)
其中R.layout.row是由textView组成的row.xml
而R.id.textView2是行中存在的textView的id。xml创建两个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"
android:orientation="vertical"
android:background="@drawable/bkgrnd_320x285">
<ListView
android:id="@+id/List1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="#000000"
android:dividerHeight="1dp"
android:fastScrollEnabled="true"/>
</LinearLayout>
另一个xml仅用于textView,例如row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Display Name"
android:textSize="20dp"
android:layout_marginTop="20dp" />
</LinearLayout>
然后在主活动中,您需要引用两个xml文件,如下所示
ListView ll=(ListView)findViewById(R.id.List1)
ArrayAdapter ArrayAdapter=新的ArrayAdapter(这是,R.layout.row,R.id.textView2,arraylist,您希望显示)
ll.设置适配器(阵列适配器)
其中R.layout.row是由textView组成的row.xml
R.id.textView2是行中文本视图的id。xml您可以创建线性布局,将方向设置为垂直 添加ScrollView或ListView以显示上部,android:weight=1 将EditText添加到LinearLayout,即可完成此操作
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/List1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:weight="1"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
您可以创建线性布局,将方向设置为垂直 添加ScrollView或ListView以显示上部,android:weight=1 将EditText添加到LinearLayout,即可完成此操作
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/List1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:weight="1"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
为此目的使用列表视图请参阅为此目的使用列表视图请参阅