0

I write app for Android such gets data from server in JSON format. Now I get this value in string, but in my application it must look like:

Route:

  • 1)first point

  • 2)secon point

  • 3).....
  • n) n point

I read that in Android in textView I can do it if string will be with html tags but I think it is not the best variant. After Android I must do it in iPhone now I don't know how to do that there. Send Routes as Array is not good variant too. Can you say what is the best way to decide this problem?

Abbath
  • 1,002
  • 13
  • 30

2 Answers2

0

I couldn't comment b/c of rep, sorry. Could you provide an example of returned JSON string. I think JSON format can be parsed with ease.

If this the case you can parse it in a loop (or another way. I'm not that good at it)

String[] parseIt (String JSON){
    String[] list=JSON.split("\\d\\)");
    String[] rlist=new String[list.length-1];
    for(int i=0;i<list.length-1;i++){
        rlist[i]=list[i+1].trim();
    }
    return rlist;
} 

This might do trick. But you should edit result. I didn't test yet

Edit: I edited code. It simply return the address now with leading whitespace. You can get rid off them using. String trim() method like;

list[1].trim();

Do it in loop and don't care about first element (index 0).

Edit 2: Now it should work

mgokgoz
  • 186
  • 1
  • 9
0

Have a look here you will have to find the good pattern .

Hence you have separated strings just use a list View with an ArrayAdapter.

I am not so good with regex but i think it should like : [1-9][0-9]) [[a-f][0-9]]+

Community
  • 1
  • 1
HoodVinci
  • 656
  • 5
  • 7