【发布时间】:2012-06-30 14:14:23
【问题描述】:
我正在编写一个 android 应用程序,但在使用 CheckBox 获取 ListView 中的行位置时遇到问题。
这是模拟器的截图:
我已经用 CheckBoxes 制作了ListView。但我不知道如何找到每个选中条目的行位置。一旦我得到选中的位置,我想实现一个 Remove Selected 动作。
请帮忙!
这是我的代码:
public class ListTest extends ListActivity implements OnCheckedChangeListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
//--- Importing StringsArray---
Bundle gotBasketScanner = getIntent().getExtras();
String[] StringArrayHistory = gotBasketScanner.getStringArray("fromHistory");
// ---Make Adapter---
setListAdapter( new ArrayAdapter<String>(ListTest.this,
android.R.layout.simple_list_item_multiple_choice,
StringArrayHistory));
// ---Put Array into a ListView and add Checkboxes to Listview
ListView list = getListView();
list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
}
}
【问题讨论】:
-
如果您有解决方案,请接受答案:)
标签: android android-listview listactivity