从项目列表中自动选择
我有一堂课向我显示了项目列表。现在我正在通过单击(setOnItemClickListener)选择此项目,但我不想要这样。我想要的是:当我自动打开课程时,选择列表中的最后一项。
谁能告诉我该怎么做?
感谢您的帮助
public class SelectCodIncidence extends Activity {
private ArrayList<String> datos;
protected netAppApplication app;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.codincidence);
datos = new ArrayList<String>();
//datosCod = new ArrayList<String>();
try {
NotesCenter messageCenter = new NotesCenterImpl();
List<CodIncidence> codincidence = messageCenter.getCodIncidence();
for (CodIncidence e : codincidence) {
//datosCod.add("1");
datos.add(e.id);
}
} catch (Exception ex) {
// showMessage(ex);
Log.v("blah", ex.getMessage());
}
ArrayAdapter<String> adaptador =
new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, datos);
final TextView lblMessage = (TextView)findViewById(R.id.MensajeCodIncidence);
final GridView grdOptions = (GridView)findViewById(R.id.GridCodIncidence);
grdOptions.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, android.view.View v, int position, long id) {
CodIncidence codincidenceSelected = new CodIncidence();
codincidenceSelected.id = datos.get(position);
app = (netAppApplication)getApplicationContext();
app.setcodincidenceActual(codincidenceSelected);
SharedPreferences prefs = getSharedPreferences("netAppSetup",2);
SharedPreferences.Editor editor = prefs.edit();
editor.putString("CODINCIDENCE", codincidenceSelected.id);
editor.commit();
finish();
}
});
grdOptions.setAdapter(adaptador);
}
}
I have one class that shows me a list of Items. Right now I am selecting this items with click (setOnItemClickListener), but i don't want that. What i want is: when i open the class automatically is selecting the last item on the list.
Can anyone tell me how I can do it?
Thanks for any help
public class SelectCodIncidence extends Activity {
private ArrayList<String> datos;
protected netAppApplication app;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.codincidence);
datos = new ArrayList<String>();
//datosCod = new ArrayList<String>();
try {
NotesCenter messageCenter = new NotesCenterImpl();
List<CodIncidence> codincidence = messageCenter.getCodIncidence();
for (CodIncidence e : codincidence) {
//datosCod.add("1");
datos.add(e.id);
}
} catch (Exception ex) {
// showMessage(ex);
Log.v("blah", ex.getMessage());
}
ArrayAdapter<String> adaptador =
new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, datos);
final TextView lblMessage = (TextView)findViewById(R.id.MensajeCodIncidence);
final GridView grdOptions = (GridView)findViewById(R.id.GridCodIncidence);
grdOptions.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, android.view.View v, int position, long id) {
CodIncidence codincidenceSelected = new CodIncidence();
codincidenceSelected.id = datos.get(position);
app = (netAppApplication)getApplicationContext();
app.setcodincidenceActual(codincidenceSelected);
SharedPreferences prefs = getSharedPreferences("netAppSetup",2);
SharedPreferences.Editor editor = prefs.edit();
editor.putString("CODINCIDENCE", codincidenceSelected.id);
editor.commit();
finish();
}
});
grdOptions.setAdapter(adaptador);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的东西:
Something like: