Error rendering map android

I'm trying to read this text file and render the corresponding tiles on the screen.

Error rendering map android

The code for reading the map is as follows:

private void loadMap(InputStream is) throws IOException {     ArrayList<String> lines = new ArrayList<String>();     int width = 0;     int height = 0;      BufferedReader reader = new BufferedReader(new InputStreamReader(is));     while (true) {         String line = reader.readLine();         if (line == null) {             reader.close();             break;         }          if (!line.startsWith("!")) {             lines.add(line);             width = Math.max(width, line.length());         }     }     height = lines.size();      for (int j=0; j < 18; j++) {         String line = (String) lines.get(j);         for (int i=0; i < width; i++) {              if (i < line.length()) {                 char ch = line.charAt(i);                 Tile t = new Tile(i, j, Character.getNumericValue(ch));                 tiles.add(t);             }         }     }  } 

The first problem I have is with Character.getNumericValue(ch) as this does not seem to be doing anything, resulting in a NullPointerException. When I remove it and replace it with either a 1 or a 2 I'm able to render the tiles onto the screen but somehow the spaces in between the digits are interpreted as tiles, resulting in a continuous block of tiles eg in the second line with 1s results in tiles beginning from the left margin up until the last 1. How can I fix this?

Replay

Category: android Time: 2015-10-15 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.232 (s). 12 q(s)