public class ListView1Activity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_view1);
overridePendingTransition(android.R.anim.slide_in_left,android.R.anim.slide_out_right);
ListView listview2=(ListView) findViewById(R.id.listview2);
SimpleAdapter simpleadapt=new SimpleAdapter(this, getFriendData(),R.layout.listview,
new String[]{"name","age","addr","pic"},
new int[]{R.id.name,R.id.age,R.id.addr,R.id.pic});
listview2.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView> parent, View view,
int position, long id) {
Toast.makeText(getApplicationContext(), "你选了"+parent.getItemIdAtPosition(position)+"美女", 200).show();
}
@Override
public void onNothingSelected(AdapterView> parent) {
}
});
listview2.setAdapter(simpleadapt);
}
//获得数据
private List
布局文件如下: