在我的应用程序中,我实现了ListView
。 现在我想它设置为像这样:如果我选择特定指数,它应该保持为选定。 ans显示为ListView
。 如果我选择另一个索引,那么现在新索引应该保持为选定状态。如何保持选中并突出显示的listView索引?
编辑
意味着我要设置为所选指数应继续作为选择,直到我选择另一所强调的。但不喜欢多选。
那么怎么办呢?
请帮我了点。 我已经实现了ListView
像下面的代码:
phonemesListView = (ListView) findViewById(R.id.phonemsListView);
private String[] Phonemes_List = new String[]{"P","B","T","D","K","G","N","M","ING","TH v","TH vl","F","V","S","Z","SH","CH","J","L","R rf","R b"};
phonemesListView.setAdapter(new ArrayAdapter<String>(this,R.layout.phonemes_list_row, R.id.phonemes,Phonemes_List));
@Override
public void onItemClick(AdapterView<?> parent, View view,final int Position,long id) {
phonemsText.setText(Phonemes_List[Position]);
Toast.makeText(getApplicationContext(), "Phonems: "+Phonemes_List[Position], Toast.LENGTH_SHORT).show();
// view.setBackgroundColor(Color.RED);
// phonemesListView.setBackgroundColor(Color.BLUE);
jumposition = Position;
int temp = 0;
if(jumpCount == -1){
view.setBackgroundColor(Color.BLUE);
jumpCount = jumposition;
JumpView = view;
temp = 1;
}
if(temp == 0) {
if(jumpCount == jumposition) {
view.setBackgroundColor(Color.BLUE);
JumpView = view;
}
else{
JumpView.setBackgroundColor(Color.TRANSPARENT);
view.setBackgroundColor(Color.BLUE);
jumpCount = jumposition;
JumpView = view;
}
}
}
感谢。
这篇文章可以给你一些有识之士http://stackoverflow.com/questions/3825645/android-listview-with-multiple-select-and-custom-adapter并尝试listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); :) – 2012-01-17 12:43:48
@SergeyBenner:请参阅更新的问题。 – 2012-01-17 12:57:26