通过使用Jsoup,我从网站解析HTML以填充ArrayList我需要从网站获取的内容.所以现在我有一个ArrayList充满字符串的东西.我想在该列表中找到包含特定字符串的索引.例如,我知道列表中的某个地方,在某个索引中,有字符串(文字)"Claude",但我似乎无法制作任何代码,找到contains"Claude"中的索引ArrayList...这里是我尝试过但返回-1(未找到):
ArrayList < String > list = new ArrayList < String > ();
String claude = "Claude";
Document doc = null;
try {
doc = Jsoup.connect("http://espn.go.com/nhl/team/stats/_/name/phi/philadelphia-flyers").get();
} catch (IOException e) {
e.printStackTrace();
}
for (Element table: doc.select("table.tablehead")) {
for (Element row: table.select("tr")) {
Elements tds = row.select("td");
if (tds.size() > 6) {
String a = tds.get(0).text() + tds.get(1).text() + tds.get(2).text() + tds.get(3).text() + tds.get(4).text() + tds.get(5).text() + tds.get(6).text();
list.add(a);
int …Run Code Online (Sandbox Code Playgroud) 所以我有一个ScrollView作为我的布局中的最高级...在我的ScrollView中我有一个包含其他视图的RelativeLayout.问题是RelativeLayout没有覆盖整个布局,它切断了大约一半的屏幕.它的宽度是屏幕的整个宽度,但RelativeLayout的高度停在ImageView底部的位置.这是我的布局代码:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="@drawable/graybck">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/pPicture"
android:layout_width="200dip"
android:layout_height="300dip"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
<TextView
android:id="@+id/pName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="29dp"
android:layout_toRightOf="@+id/pPicture"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/pBio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/pName"
android:layout_below="@+id/pName"
android:layout_marginTop="22dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/stats"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/pName"
android:layout_marginRight="266dp"
android:text="Loading Stats..." />
</RelativeLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
任何帮助深表感谢!
我有一个IntentService连接到一个网站,并通过JSoup创建一个解析HTML的列表.我现在需要将该列表传回一个Bundle,我不知道该怎么做.这是我的代码IntentService:
public class NewerService extends IntentService {
public NewerService() {
super("NewerService");
// TODO Auto-generated constructor stub
}
@Override
protected void onHandleIntent(Intent intent) {
ResultReceiver rec = intent.getParcelableExtra("receiverTag");
String playersName = intent.getStringExtra("Player");
List<String> list = new ArrayList<String>();
Document doc = null;
try {
doc = Jsoup.connect("http://espn.go.com/nhl/team/stats/_/name/phi/philadelphia-flyers").get();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
for (Element table : doc.select("table.tablehead")) {
for (Element row : table.select("tr")) {
Elements tds = row.select("td");
if …Run Code Online (Sandbox Code Playgroud)