动态ListView扩展了Activity

时间:2010-09-26 13:32:07

标签: android listview dynamic android-activity listactivity

当课程没有延长ListView时,我是否可以创建动态填充的ListActivity

我很感激帮助。

1 个答案:

答案 0 :(得分:2)

是。例如:

public class StoreListActivity extends Activity {
    private List<Store> mStores;
    private StoreAdapter mStoreAdapter;
    private ListView mListView;

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

            mStores = getTheStoresFromSomewhere();
        mStoreAdapter = new StoreAdapter(this, mStores);
        mListView.setAdapter(mStoreAdapter);
    }