我有一个 Android 应用程序,它将从预先指定的 Web URL 读取名为 getFuelStops() 的 asp.net webservice 方法。下面是对 getFuelStops() 的 Web 服务调用的内容。
getFuelStops() 的 Web 服务结果
<FuelStop>
<Physical_Address_Street>3100 Church</Physical_Address_Street>
<Physical_Address_Local> Chesapeake</Physical_Address_Local>
<Physical_Address_State>VA</Physical_Address_State>
<Physical_Address_Zip>23321</Physical_Address_Zip>
<Phone_Number>555-555-5555</Phone_Number></FuelStop>
<FuelStop>
<FuelStop>
<Physical_Address_Street>3102 Church</Physical_Address_Street>
<Physical_Address_Local> Chesapeake</Physical_Address_Local>
<Physical_Address_State>VA</Physical_Address_State>
<Physical_Address_Zip>23321</Physical_Address_Zip>
<Phone_Number>555-555-5555</Phone_Number></FuelStop>
<FuelStop>
<FuelStop>
<Physical_Address_Street>3103 Church</Physical_Address_Street>
<Physical_Address_Local> Chesapeake</Physical_Address_Local>
<Physical_Address_State>VA</Physical_Address_State>
<Physical_Address_Zip>23321</Physical_Address_Zip>
<Phone_Number>555-555-5555</Phone_Number>
</FuelStop>
然后我的 Android 应用程序中有一个活动。并显示为 TableLayout。
我需要此活动以将上面的地址列表作为列表读取。对于地址,我需要将 Physical_Address_Street、Physcial_Address_Local、Physcial_Address_State 和 Physcial_Address_Zip 都与字符串生成器连接在一起,并将电话作为单独的字符串。我的第一个问题是,我可以使用 KSOAP2 来执行此操作,还是必须为此使用 RESTFul 阅读器?就示例而言,我将如何做到这一点。
FuelStopActivity.java
public class FuelStopActivity extends Activity {
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SuppressLint("InlinedApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fuel_stop);
displayFuleStopTable();
}
private void displayFuleStopTable(){
List<FuelStops> subwayList = new ArrayList<FuelStops>();
ScrollView sv = new ScrollView(this);
TableLayout ll = (TableLayout) findViewById(R.id.TableLayout01);
HorizontalScrollView hsv = new HorizontalScrollView(this);
}
}