package com.sxt.day05_03;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class MainActivity extends Activity {
ListView mlvWeek;
ArrayAdapter<CharSequence> mAdapter;//CharSequence是安卓中的接口,字符序列
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}
private void initView() {
mlvWeek=(ListView) findViewById(R.id.lvWeek);
mAdapter=ArrayAdapter.createFromResource(this,
R.array.day_of_week, //字符串数组
android.R.layout.simple_expandable_list_item_1);//simple_expandable_list_item_1是布局,安卓系统的Item
mlvWeek.setAdapter(mAdapter);
}
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/lvWeek"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>