简易列表
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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="com.hanqi.zuoye.liebiaoviewActivity"> <ListView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/lv"></ListView> </LinearLayout>
显示界面
<?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="20sp" android:paddingTop="10dp" android:paddingBottom="10dp"/>
准备的列表样界面
package com.hanqi.zuoye; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.ArrayAdapter; import android.widget.ListView; public class liebiaoviewActivity extends AppCompatActivity { ListView lv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_liebiaoview); lv=(ListView)findViewById(R.id.lv); //1-数据集合 Layout文件 String []st={"A1","A2","A3","A4","A5","A6","A7","A8","A9","A0","A1","A2","A3","A4","A5","A6","A7","A8","A9","A0",}; //创建Adpter ArrayAdapter<String> arrayAdapter=new ArrayAdapter<String>(this,R.layout.array_liebiao,st); //绑定到ListView lv.setAdapter(arrayAdapter); } }
java代码