2014-09-22 47 views
0

我有一個字符串是在HTML中,我想要得到它並將其添加到我的ArraryList。如何獲取HTML字符串

ArrayList<Adapter> strings = new ArrayList<Adapter>(); 
///------------///// 
//////////////////// 
strings.add(new Adapter("", "")); 

字符串:

<string name="stringg"><![CDATA[<b>Title</b><br><small>Description]]></string> 

我試圖strings.add(new Adapter(""+R.string.stringg, ""));但談到了一些。

適配器代碼:

public class Adapter{ 
public String first; 
public String last; 
public Code(String first, String last) { 
this.first = first; 
this.last = last; 
} 
public static ArrayList<Adapter> getCodes() { 
ArrayList<Adapter> strings = new ArrayList<Adapter>(); 

    strings.add(new Adapter("", "")); 

return codes; 
} 
} 
+0

你嘗試'getResources()。getString(R.string.stringg)'? – 2014-09-22 18:42:08

+0

@ρяσѕρєяK我得到「該方法getResources()是未定義的類型適配器」 – 2014-09-22 18:43:22

+0

顯示適配器「類代碼 – 2014-09-22 18:45:24

回答

0

做它通過傳遞活動上下文getCodes訪問getResources()方法:

public static ArrayList<Adapter> getCodes(Context mContext) { 
ArrayList<Adapter> strings = new ArrayList<Adapter>(); 

    strings.add(new 
      Adapter(mContext.getResources().getString(R.string.stringg), "")); 

return codes; 
} 
+0

謝謝你的男人! – 2014-09-22 18:58:33

0

你可以嘗試belove代碼

getString(R.string.stringg) 
+0

同樣的錯誤./ – 2014-09-22 18:51:54