gpt4 book ai didi

android - 动态 ListView 扩展 Activity

转载 作者:行者123 更新时间:2023-11-29 22:31:29 24 4
gpt4 key购买 nike

当类不扩展 ListActivity 时,我是否可以创建一个动态填充的 ListView

感谢您的帮助。

最佳答案

是的。示例:

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);
}

关于android - 动态 ListView 扩展 Activity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3797992/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com