- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在创建两个 java 文件,一个是 Main.java 和 Category.java
我正在添加库文件 ksoap2-android-assembly-2.6.2-jar-with-dependencies.jar
但是这里没有显示输出。
我正在做 soap XMl 解析。
这里是 TextView ,但我想要一个列表。请帮助我
主.java
public class Main extends Activity {
private static String SOAP_ACTION = "http://tempuri.org/HelloWorld";
private static String NAMESPACE = "http://tempuri.org/";
private static String METHOD_NAME = "HelloWorld";
private static String URL = "http://sygnetinfosol.com/webservice.asmx";
/** Called when the activity is first created. */
@SuppressWarnings("static-access")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Initialize soap request + add parameters
// SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapObject request = GetSoapObject(METHOD_NAME);
SoapSerializationEnvelope envelope = GetEnvelope(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
envelope.addMapping(NAMESPACE, "Category",new Category().getClass());
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject response = (SoapObject) envelope.getResponse();
Category[] Allrooms = RetrieveFromSoap(response);
TextView actv = (TextView)findViewById(R.id.resultbox);
actv.setHint(Allrooms[0].Text1);
} catch (Exception e) {
e.printStackTrace();
}
}
public static SoapObject GetSoapObject(String MethodName)
{
return new SoapObject(NAMESPACE,MethodName);
}
public static SoapSerializationEnvelope GetEnvelope(SoapObject Soap)
{
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(Soap);
return envelope;
}
public static Category[] RetrieveFromSoap(SoapObject soap)
{
Category[] categories = new Category[soap.getPropertyCount()];
for (int i = 0; i < categories.length; i++) {
SoapObject pii = (SoapObject)soap.getProperty(i);
Category category = new Category();
Category.Text1 = pii.getProperty(0).toString();
Category.Text2= pii.getProperty(1).toString();
Category.Text3= pii.getProperty(2).toString();
categories[i] = category;
}
return categories;
}
}
分类.java
public class Category implements KvmSerializable{
public static String Text1;
public static String Text2;
public static String Text3;
public Category(){}
public Category(String lat, String longi, String address) {
Text1 = lat;
Text2 = longi;
Text3 = address;
}
public Object getProperty(int arg0) {
switch(arg0)
{
case 0:
return Text1;
case 1:
return Text2;
case 2:
return Text3;
}
return null;
}
public int getPropertyCount() {
return 3;
}
public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info) {
switch(index)
{
case 0:
info.type = PropertyInfo.STRING_CLASS;
info.name = "Text1";
break;
case 1:
info.type = PropertyInfo.STRING_CLASS;
info.name = "Text2";
break;
case 2:
info.type = PropertyInfo.STRING_CLASS;
info.name = "Text3";
break;
default:break;
}
}
public void setProperty(int index, Object value) {
switch(index)
{
case 0:
Text1 = value.toString();
break;
case 1:
Text2 = value.toString();
break;
case 2:
Text3 = value.toString();
break;
default:
break;
}
}
}
日志猫
03-14 11:59:05.417: W/PackageManager(59): Code path for pkg : com.pxr.tutorial.soap.weather changing from /data/app/com.pxr.tutorial.soap.weather-2.apk to /data/app/com.pxr.tutorial.soap.weather-1.apk
03-14 11:59:05.417: W/PackageManager(59): Resource path for pkg : com.pxr.tutorial.soap.weather changing from /data/app/com.pxr.tutorial.soap.weather-2.apk to /data/app/com.pxr.tutorial.soap.weather-1.apk
03-14 11:59:05.422: D/PackageManager(59): Activities: com.pxr.tutorial.soap.weather.Main
03-14 11:59:05.462: I/ActivityManager(59): Force stopping package com.pxr.tutorial.soap.weather uid=10039
03-14 11:59:06.276: I/installd(35): move /data/dalvik-cache/data@app@com.pxr.tutorial.soap.weather-1.apk@classes.dex -> /data/dalvik- cache/data@app@com.pxr.tutorial.soap.weather-1.apk@classes.dex
03-14 11:59:06.282: D/PackageManager(59): New package installed in /data/app/com.pxr.tutorial.soap.weather-1.apk
03-14 11:59:07.162: D/dalvikvm(257): GC_EXPLICIT freed 154 objects / 11496 bytes in 87ms
03-14 11:59:07.192: I/ActivityManager(59): Force stopping package com.pxr.tutorial.soap.weather uid=10039
03-14 11:59:07.282: D/dalvikvm(119): GC_EXPLICIT freed 791 objects / 44936 bytes in 85ms
03-14 11:59:07.392: D/dalvikvm(59): GC_EXPLICIT freed 9323 objects / 576216 bytes in 149ms
03-14 11:59:07.662: W/RecognitionManagerService(59): no available voice recognition services found
03-14 11:59:07.872: D/dalvikvm(157): GC_EXPLICIT freed 1881 objects / 96152 bytes in 421ms
03-14 11:59:07.982: D/dalvikvm(59): GC_EXPLICIT freed 4037 objects / 225296 bytes in 105ms
03-14 11:59:08.042: I/installd(35): unlink /data/dalvik-cache/data@app@com.pxr.tutorial.soap.weather-2.apk@classes.dex
03-14 11:59:08.102: D/AndroidRuntime(575): Shutting down VM
03-14 11:59:08.112: D/dalvikvm(575): Debugger has detached; object registry had 1 entries
03-14 11:59:08.702: D/AndroidRuntime(588): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
03-14 11:59:08.702: D/AndroidRuntime(588): CheckJNI is ON
03-14 11:59:08.852: D/AndroidRuntime(588): --- registering native functions ---
03-14 11:59:09.572: I/ActivityManager(59): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.pxr.tutorial.soap.weather/.Main }
03-14 11:59:09.912: I/ActivityManager(59): Start proc com.pxr.tutorial.soap.weather for activity com.pxr.tutorial.soap.weather/.Main: pid=594 uid=10039 gids={3003}
03-14 11:59:09.922: D/AndroidRuntime(588): Shutting down VM
03-14 11:59:09.922: D/jdwp(588): Got wake-up signal, bailing out of select
03-14 11:59:09.922: D/dalvikvm(588): Debugger has detached; object registry had 1 entries
03-14 11:59:09.952: I/dalvikvm(588): JNI: AttachCurrentThread (from ???.???)
03-14 11:59:09.952: I/AndroidRuntime(588): NOTE: attach of thread 'Binder Thread #3' failed
03-14 11:59:11.171: I/ActivityManager(59): Displayed activity com.pxr.tutorial.soap.weather/.Main: 1269 ms (total 1269 ms)
03-14 11:59:16.412: D/dalvikvm(119): GC_EXPLICIT freed 728 objects / 42320 bytes in 158ms
03-14 11:59:21.422: D/dalvikvm(265): GC_EXPLICIT freed 109 objects / 5360 bytes in 150ms
最佳答案
ok I will send you all the classes and xml files. check and learn the web services concept.
LazyAdapter.java
public class LazyAdapter extends BaseAdapter {
java.net.URL urlImage;
InputStream is ;
private Activity activity;
private ArrayList<HashMap<String, String>> twitterList;
private static LayoutInflater inflater=null;
public LazyAdapter(Activity a, ArrayList<HashMap<String, String>> d) {
activity = a;
twitterList=d;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
return twitterList.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.list_item, null);
TextView id = (TextView)vi.findViewById(R.id.playerId); // title
TextView name = (TextView)vi.findViewById(R.id.playerName); // artist name
TextView country = (TextView)vi.findViewById(R.id.countryName); // duration
ImageView flag=(ImageView)vi.findViewById(R.id.countryFlag); // thumb image
HashMap<String, String> valueList = new HashMap<String, String>();
valueList = twitterList.get(position);
// Setting all values in listview
id.setText(valueList.get(WSDemoFootBallActivity.TAG_ID));
name.setText(valueList.get(WSDemoFootBallActivity.TAG_NAME));
country.setText(valueList.get(WSDemoFootBallActivity.TAG_COUNTRYNAME));
String countryFlag = valueList.get(WSDemoFootBallActivity.TAG_COUNTRYFLAG);
try {
urlImage = new java.net.URL(countryFlag);
is = (InputStream) urlImage.getContent();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Drawable d = Drawable.createFromStream(is, null);
flag.setImageDrawable(d);
return vi;
}
}
SingleMenuItemActivity.java
public class SingleMenuItemActivity extends Activity {
URL url;
Bitmap bimage;
java.net.URL urlImage;
InputStream is ;
private static final String TAG_ID = "id";
private static final String TAG_NAME = "name";
private static final String TAG_COUNTRYNAME = "countryName";
private static final String TAG_COUNTRYFLAG = "countryFlag";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.single_list_item);
// getting intent data
Intent in = getIntent();
// Get JSON values from previous intent
String playerId = in.getStringExtra(TAG_ID);
String playerName = in.getStringExtra(TAG_NAME);
String countryName = in.getStringExtra(TAG_COUNTRYNAME);
String countryFlag = in.getStringExtra(TAG_COUNTRYFLAG);
// Displaying all values on the screen
TextView lblId = (TextView) findViewById(R.id.playerId);
TextView lblName = (TextView) findViewById(R.id.playerName);
TextView lblCountryName = (TextView) findViewById(R.id.countryName);
ImageView lblCountryFlag = (ImageView) findViewById(R.id.countryFlag);
try {
urlImage = new java.net.URL(countryFlag);
is = (InputStream) urlImage.getContent();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Drawable d = Drawable.createFromStream(is, null);
lblId.setText(playerId);
lblName.setText(playerName);
lblCountryName.setText(countryName);
lblCountryFlag.setImageDrawable(d);
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<!-- Main ListView
Always give id value as list(@android:id/list)
-->
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp" >
<ImageView
android:id="@+id/countryFlag"
android:layout_width="70dp"
android:layout_height="50dp"
android:gravity="left"
android:src="@drawable/ic_launcher" >
</ImageView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:orientation="vertical" >
<TextView
android:id="@+id/playerId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="2dip"
android:paddingTop="6dip"
android:textColor="#43bd00"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/playerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="2dip"
android:textColor="#acacac" >
</TextView>
<TextView
android:id="@+id/countryName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:textColor="#5d5d5d" >
</TextView>
</LinearLayout>
</LinearLayout>
single_list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="2dip"
android:paddingTop="6dip"
android:text="PlayerId :"
android:textColor="#43bd00"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/playerId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="2dip"
android:paddingTop="6dip"
android:textColor="#43bd00"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="2dip"
android:text="PlayerName :"
android:textColor="#acacac"
android:textSize="16sp" >
</TextView>
<TextView
android:id="@+id/playerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="2dip"
android:textColor="#acacac" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:text="CountryName :"
android:textColor="#5d5d5d" >
</TextView>
<TextView
android:id="@+id/countryName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:textColor="#5d5d5d" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:text="CountryFlag :"
android:textColor="#43bd00" >
</TextView>
<ImageView
android:id="@+id/countryFlag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left" >
</ImageView>
</LinearLayout>
</LinearLayout>
关于Android web服务xml解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15402470/
正如标题中所问,我有两个如下结构的 XML 文件 A.xml //here I want to include B.xml
我有一个 xml 文件。根据我的要求,我需要更新空标签,例如我需要更改 to .是否可以像那样更改标签.. 谢谢... 最佳答案 var xmlString=" "; var properStri
我有这样简单的 XML: Song Playing 09:41:18 Frederic Delius Violin Son
在我的工作中,我们有自己的 XML 类来构建 DOM,但我不确定应该如何处理连续的空格? 例如 Hello World 当它被读入 DOM 时,文本节点应该包含 Hello 和 World
我有以下 2 个 xml 文件,我必须通过比较 wd:Task_Name_ID 和 TaskID 的 XML 文件 2。 例如,Main XML File-1 wd:Task_Name_ID 具有以下
我在 Rails 应用程序中有一个 XML View ,需要从另一个文件插入 XML 以进行测试。 我想说“构建器,只需盲目地填充这个字符串,因为它已经是 xml”,但我在文档中看不到这样做的任何内容
我正在重建一些 XML 提要,因此我正在研究何时使用元素以及何时使用带有 XML 的属性。 一些网站说“数据在元素中,元数据在属性中。” 那么,两者有什么区别呢? 让我们以 W3Schools 为例:
在同一个文档中有两个 XML 声明是否是格式正确的 XML? hello 我相信不是,但是我找不到支持我的消息来源。 来自 Extensible Markup Language
我需要在包装器 XML 文档中嵌入任意(语法上有效的)XML 文档。嵌入式文档被视为纯文本,在解析包装文档时不需要可解析。 我知道“CDATA trick”,但如果内部 XML 文档本身包含 CDAT
XML 解析器和 XML 处理器是两个不同的东西吗?他们是两个不同的工作吗? 最佳答案 XML 解析器和 XML 处理器是一样的。它不适用于其他语言。 XML 是通用数据标记语言。解析 XML 文件已
我使用这个 perl 代码从一个文件中读取 XML,然后写入另一个文件(我的完整脚本有添加属性的代码): #!usr/bin/perl -w use strict; use XML::DOM; use
我正在编写一个我了解有限的历史脚本。 对象 A 的类型为 system.xml.xmlelement,我需要将其转换为类型 system.xml.xmldocument 以与对象 B 进行比较(类型
我有以下两个 XML 文件: 文件1 101 102 103 501 502 503
我有以下两个 XML 文件: 文件1 101 102 103 501 502 503
我有一个案例,其中一个 xml 作为输入,另一个 xml 作为输出:我可以选择使用 XSL 和通过 JAXB 进行 Unmarshalling 编码。性能方面,有什么真正的区别吗? 最佳答案 首先,程
我有包含 XML 的 XML,我想使用 JAXB 解析它 qwqweqwezxcasdasd eee 解析器 public static NotificationRequest parse(Strin
xml: mario de2f15d014d40b93578d255e6221fd60 Mario F 23 maria maria
尝试更新 xml 文件数组时出现以下错误。 代码片段: File dir = new File("c:\\XML"); File[] files = dir.listFiles(new Filenam
我怎样才能完成这样的事情: PS /home/nicholas/powershell> PS /home/nicholas/powershell> $date=(Get-Date | ConvertT
我在从 xml 文件中删除节点时遇到一些困难。我发现很多其他人通过各种方式在 powershell 中执行此操作的示例,下面的代码似乎与我见过的许多其他示例相同,但我没有得到所需的行为。 我的目标是将
我是一名优秀的程序员,十分优秀!