How to display in the ListView a single data from a query that returns two data?

3

I have a query that returns a person's first and last name. With the result of this query , I enter the information inside a ListView and the first and last name is displayed.

How do I display only the name?

And then I would have to use the string name using arraAdapter.getItem(position); but also get only the name, could not come the last name.

    

asked by anonymous 29.07.2015 / 16:01

1 answer

1

You can separate the name by the spaces using .split(); , it will separate its string into an array according to the separator field that you enter as a parameter.

Example to solve your problem:

String nomeCompleto= "JOÃO DA SILVA";  
String array[] = nomeCompleto.split(" "); 
String primeiroNome = array[0];
    
14.09.2015 / 15:48