Android APP開發活用範例速查大辭典(Ch0201-簡易ListView用法)

Android APP開發活用範例速查大辭典(Ch0201-簡易ListView用法)

Android APP開發活用範例速查大辭典(Ch0201-簡易ListView用法)

 

片段程式碼

public class Ch0201 extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ch0201_main);
ListView listView = (ListView) findViewById(R.id.ListView);

// 建立Adapter
ListAdapter adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, DAYS);
// 設定Adapter
listView.setAdapter(adapter);
}

// 要顯示在ListView的字串
private static final String[] DAYS = new String[] { “Sunday”, “Monday”,
“Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday” };

}

 

 

 


發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *