0

我正在尝试从 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 参数。

4

2 回答 2

0

单击项目以获取子文件夹时,是否需要将参数传递给 Web 服务?如果是这样,它是索引号还是父文件夹的名称?

于 2013-02-14T07:49:48.617 回答
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");
于 2013-02-14T07:21:11.667 回答