我正试图从Listview获取id。我使用了arrayadapter并使用了itemclick。我想点击特定列表项并转到下一个活动,以便我可以访问子文件夹。我正在使用(ksoap).net网络服务。
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参数中。感谢
答案 0 :(得分:0)
试试这个: 我希望这对你有帮助..如果你需要你使用它..
listview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
Object o = listview.getItemAtPosition(arg2);
String des = o.toString();
Intent myIntent = new Intent(arg1.getContext(), Next_Activity.class);
myIntent.putExtra("id", des);
startActivity(myIntent);
}
});
这用于获取以前活动的意图值:
Bundle b = new Bundle();
b = getIntent().getExtras();
String id_backup= b.getString("id");
答案 1 :(得分:0)
单击某个项目以获取子文件夹时,是否需要将参数传递给Web服务?如果是这样的索引号或父文件夹的名称?