2016-08-19 2 views

Antwort

1

Dafür sollten Sie Debug-Punkte verwenden. Sie können eine vollständige Antwort erhalten und Schritt für Schritt die Ausführung Ihres Codes sehen. Weitere können Sie in der unten genannten Webseite gehen:

https://developer.android.com/studio/debug/index.html

+0

Ja auslesen kann, sein, der beste Weg. Vielen Dank. –

0

Eine benutzerdefinierte Klasse dafür erstellen. Die wichtigste Methode für die Verwendung in Ihrem Code ist splitAndLog von @pctroll.

public class Utils { 
     /** 
     * Divides a string into chunks of a given character size. 
     * 
     * @param text     String text to be sliced 
     * @param sliceSize    int Number of characters 
     * @return ArrayList<String> Chunks of strings 
     */ 
     public static ArrayList<String> splitString(String text, int sliceSize) { 
      ArrayList<String> textList = new ArrayList<String>(); 
      String aux; 
      int left = -1, right = 0; 
      int charsLeft = text.length(); 
      while (charsLeft != 0) { 
       left = right; 
       if (charsLeft >= sliceSize) { 
        right += sliceSize; 
        charsLeft -= sliceSize; 
       } 
       else { 
        right = text.length(); 
        aux = text.substring(left, right); 
        charsLeft = 0; 
       } 
       aux = text.substring(left, right); 
       textList.add(aux); 
      } 
      return textList; 
     } 

     /** 
     * Divides a string into chunks. 
     * 
     * @param text     String text to be sliced 
     * @return ArrayList<String> 
     */ 
     public static ArrayList<String> splitString(String text) { 
      return splitString(text, 80); 
     } 

     /** 
     * Divides the string into chunks for displaying them 
     * into the Eclipse's LogCat. 
     * 
     * @param text  The text to be split and shown in LogCat 
     * @param tag  The tag in which it will be shown. 
     */ 
     public static void splitAndLog(String tag, String text) { 
      ArrayList<String> messageList = Utils.splitString(text); 
      for (String message : messageList) { 
       Log.d(tag, message); 
      } 
     } 
    } 
Verwandte Themen