我试过android:gravity但什么也没有发生。
请帮助。
这里是我的代码:
private class SiteParser extends AsyncTask {
protected String doInBackground(String... arg) {
String output = null;
try {
HtmlHelper hh = new HtmlHelper(new URL(arg[0]));
List news = hh.getnewsByClass("TextoPrint");
for (Iterator iterator = newss.iterator(); iterator
.hasNext();) {
TagNode divElement = (TagNode) iterator.next();
output = divElement.getText().toString();
}
} catch (Exception e) {
e.printStackTrace();
}
return output;
}
protected void onPostExecute(String output) {
Bundle bundle=new Bundle();
bundle.putString("body",output);
Intent mainIntent = new Intent(act, MyView.class);
mainIntent.putExtras(bundle);
startActivity(mainIntent);
act.finish();
}
}
public class HtmlHelper {
TagNode rootNode;
public HtmlHelper(URL htmlPage) throws IOException, XPatherException {
HtmlCleaner cleaner = new HtmlCleaner();
rootNode = cleaner.clean(htmlPage);
}
List getnewsByClass(String Classname){
List newsList = new ArrayList();
TagNode divElements[] = rootNode.getElementsByName("div", true);
for (int i = 0; divElements != null && i < divElements.length; i++) {
String classType = divElements[i].getAttributeByName("id");
if (classType != null && classType.equals(Classname)) {
newsList.add(divElements[i]);
}
}
return newsList;
}
}
+0
这将有助于看到布局XML。 –