我正在尝试从 Listview 获取 id。我使用了arrayadapter 并使用了itemclick。我想单击特定列表项并移至下一个活动,以便我可以访问其中的子文件夹。我正在使用(ksoap).net Web 服务。
SoapObject dataresponse = (SoapObject)envelope.getResponse();
Log.i("myData", dataresponse.toString());
datalist = new String[dataresponse.getPropertyCount()];
for(int i=0; i< dataresponse.getPropertyCount(); i++)
datalist[i] = dataresponse.getProperty(i).toString();
treedata = (ListView)findViewById(R.id.treedata);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, datalist);
treedata.setAdapter(adapter);
treedata.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
// TODO Auto-generated method stub
// After clicking on list item I have subfolders into it, how can i get those subfolders.
// Intent intent = new Intent(getApplicationContext(), Files_Folders_Activity.class);
// int item_Id = (Integer) treedata.getAdapter().getItem(position);
// intent.putExtra("item_Id", item_Id);
// startActivity(intent);
}
});
下一个活动:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.files_folders_layout);
Intent intent = getIntent();
subfolderTreedata();
}
public void subfolderTreedata(){
try {
SoapObject subfolderrequest = new SoapObject(NAMESPACE, SUBFOLDERTREEDATA_METHOD);
subfolderrequest.addProperty("FolderID", FolderID);
subfolderrequest.addProperty("UserID", UserID);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(subfolderrequest);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION_SUBFOLDERTREEDATA , envelope);
SoapObject dataresponse = (SoapObject)envelope.getResponse();
Log.i("subfoldersData", dataresponse.toString());
subfolderslist = new String[dataresponse.getPropertyCount()];
for(int i=0;i< dataresponse.getPropertyCount(); i++)
subfolderslist[i] = dataresponse.getProperty(i).toString();
subfolderstreedata = (ListView)findViewById(R.id.subfolderstreedata);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, subfolderslist);
subfolderstreedata.setAdapter(adapter);
}
网页服务:
POST /InterLogicsMobile/InterLogics.asmx HTTP/1.1
Host: 192.168.1.5
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/TreeDataSubFolder"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<TreeDataSubFolder xmlns="http://tempuri.org/">
<FolderID>string</FolderID>
<UserId>string</UserId>
</TreeDataSubFolder>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<TreeDataSubFolderResponse xmlns="http://tempuri.org/">
<TreeDataSubFolderResult>
<FileFolderDetails>
<ID>int</ID>
<Name>string</Name>
<SubjectType>string</SubjectType>
</FileFolderDetails>
<FileFolderDetails>
<ID>int</ID>
<Name>string</Name>
<SubjectType>string</SubjectType>
</FileFolderDetails>
</TreeDataSubFolderResult>
</TreeDataSubFolderResponse>
</soap:Body>
</soap:Envelope>
请建议单击 itemclick 侦听器后如何获取子文件夹。我试图从过去 4 天得到答案。
我无法将子文件夹放入下一个活动中,我必须将 FolderId 和 UserId 都传递给 soapobject pas 参数。