Code example for TwoLineListItem

Methods: getText1, getText2

0
 
            // Set the item title and description into the view. 
            // This example does not render real HTML, so as a hack to make 
            // the description look better, we strip out the 
            // tags and take just the first SNIPPET_LENGTH chars. 
            view.getText1().setText(item.getTitle());
            String descr = item.getDescription().toString();
            descr = removeTags(descr);
            view.getText2().setText(descr.substring(0, Math.min(descr.length(), SNIPPET_LENGTH)));
            return view;
        } 
 
    } 
 
    /** 
     * Simple code to strip out <tag>s -- primitive way to sortof display HTML as 
     * plain text. 
     */ 
    public String removeTags(String str) {
        str = str.replaceAll("<.*?>", " ");
        str = str.replaceAll("\\s+", " ");