使用arrayList在listview中显示员工列表
- 员工名单:: sam, max, carl
- 必须添加哪些代码(进行更改)才能
MainActivity.java
使用 bean 类实现功能employee.java
行.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="TextView" />
雇员.java
import java.io.Serializable;
public class Employee implements Serializable{
private String Name;
public void SetName(String name){
this.Name=name;
}
public String GetName(){
return Name;
}
}
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="@+id/listView-ID"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
</ListView>
</LinearLayout>
MainActivity.java
import java.util.ArrayList;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;
public class MainActivity extends Activity {
ArrayList<Employee> AL=new ArrayList<Employee>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView TV1=(TextView) findViewById(R.id.textView1);
}
}
谢谢,