我有以下基于asynctask的代码块.我试图通过返回LoadFeed()返回List变量,并且doInBackground的返回类型是String.如果我将doInBackground的返回类型从String更改为List,那么我会收到错误
"The return type is incompatible with AsyncTask<String,Void,String>.doInBackground(String[])"
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个错误?请帮忙
谢谢,
private class DispData extends AsyncTask<String, Void, String> {
private final ProgressDialog dialog = new ProgressDialog(MessageList.this);
// can use UI thread here
protected void onPreExecute() {
dialog.setMessage("Fetching scores...");
dialog.show();
}
// automatically done on worker thread (separate from UI thread)
protected String doInBackground(final String... args) {
return loadFeed();
}
// can use UI thread here
protected void onPostExecute(final List<String> result) {
if (dialog.isShowing()) {
dialog.dismiss();
}
adapter =
new ArrayAdapter<String>(MessageList.this,R.layout.row,result);
MessageList.this.setListAdapter(adapter); …
Run Code Online (Sandbox Code Playgroud) 我有以下HTML代码,我需要解析它以检索玩家名称和他已经得分的运行.在这种情况下,它是'Ross Taylor'和9.什么是解析此信息的最佳方法?不想使用HTML解析器.REGEX是最好的方式(我知道人们对此已经死了!但我只想要这些2位信息,因此不想使用解析器)?我一直绞尽脑汁想知道如何弄清楚html文件中玩家名称的位置以及随后得分的行.下面的HTML注释部分是硬编码部分.我可以到达这个地方.然后检索标签之间的名称.这是一个很好的方法吗?另外如何在下一行中检索运行部分?
<!-- <a href="javascript:void(0);" onClick="return showHwkTooltip(this, 'lvpyrbat1');" class="livePlayerCurrent">*Luke Woodcock</a>-->
<a href="/icc_cricket_worldcup2011/content/current/player/38920.html" target="_blank" class="livePlayerCurrent" title="view the player profile for Ross Taylor">
*Ross Taylor
</a> <span style="margin-left:5px;" title="left-hand bat">(lhb)</span >
</td >
<td><b>9</b></td>
<td>9</td>
<td>1</td>
<td>0</td>
<td>100.00</td>
<td></td>
<td colspan="3" align="left"><span class="batStyl">striker</style></td>
<td></td>
<td colspan="8"></td>
</tr>
Run Code Online (Sandbox Code Playgroud)
如果您需要更多信息,请告诉我.
问候,山姆