1
My code needs to take the data from the database, in short only the following commands are missing:
if (cursor.moveToNext()) {
Contato contato = new Contato();
contato.setCodigo(cursor.getInt(cursor.getColumnIndex("ID")));
contato.setNome(cursor.getString(cursor.getColumnIndex("NOME")));
contato.setTelefone(cursor.getString(cursor.getColumnIndex("TELEFONE")));
return contato;
} else
return null;
I was wondering if it’s possible to get the data from the comic book without using it Listview or Spinner (using only Textview in just one xml layout)! So I need to take only data from one line(Row) specific to a given table, that this row will be informed by the user!
I have several contacts (name, phone, email) in the BD but I don’t want to display type all the BD contacts on main.xml
, only type 1 contact informed by the user! Someone knows kind how to get the data from BD without needing it:
adapter = new SimpleCursorAdapter(this, R.layout.contacto_list_item, cursor, columns, to);
this.setListAdapter(adapter);
That is, without having to add the layout contacto_list_item.xml
in the main.xml
, because in main I don’t want to use Listview or Spinner!
Yes, it is possible.
– Math
How do you do this? You have some tutorial link?
– carlosgoes2008
has this one: Part 1 and Part 2
– Math
Just to guide you, the site here is a Questions and Answers site. Your question does not fit very well to the purpose of the site, it would be good that you present a more specific problem, its is very comprehensive. Please tour by the website ;)
– Math
Obg for the tutorial, but to display the contacts he uses Listview in main.xml and that’s what I don’t want! I don’t want to display type all BD contacts in main, type 1 only informed by the user! You kind of know how to get the comic book data without needing it: "Adapter = new Simplecursoradapter(this, R.layout.contacto_list_item, cursor, Columns, to); this.setListAdapter(Adapter);"
– carlosgoes2008
Type I want to take the BD information directly without needing to add the layout_model: contacto_list_item.xml in the main.xml layout
– carlosgoes2008
Wow, your question is starting to get more specific, cool.. maybe you should explain it better in your question by editing it instead of adding comments
– Math
Okay, but do you have any idea?
– carlosgoes2008
It’s not very clear what you’re asking...
– Felipe Avelar
Sorry if I was unclear! But my problem has been solved! Only these commands are missing here: if (cursor.moveToNext()) { Contact = new Contact(); contact.setCodigo(cursor.getInt(cursor.getColumnIndex("ID"))); contact.setName(cursor.getString(cursor.getColumnIndex("NAME"))); contact.setTelephone(cursor.getString(cursor.getColumnIndex("PHONE")); Return contact; } Else Return null;
– carlosgoes2008
If you found the answer you should post it as such, using the square of the answers. You must then accept it so that it no longer appears in the unanswered questions.
– ramaral