【发布时间】:2014-05-26 22:22:01
【问题描述】:
有没有办法改变listview中的文本,它由ArrayAdapter填充?
我的数组:
public String[] trainingstage = {"Hello", "Hello 2"};
阵列适配器
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
android.R.layout.simple_list_item_1, trainingstage);
setListAdapter(adapter);
ListView listView = getListView();
listView.setOnItemClickListener(this);
项目:
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
switch (position) {
//untrained
case 0:
//here the text in the listview should change from "Hello" to "BYE"
case 1:
//here the text in the listview should change from "Hello 2" to "BYE 2"
}
感谢您的帮助!
【问题讨论】:
-
你应该使用
getItemAtPosition -
我应该在哪里使用这个?
-
我正在研究一个例子。
标签: android listview text android-arrayadapter onitemclicklistener