English 中文(简体)
使用编辑文本和按钮使用网络服务
原标题:consuming web service from android eclipse using edittext and button

现在我正在用“强势”SOAP GeetBibleWordsbyKeyWordd in android paper。

在这里,我需要从第1页的编辑文本框中从用户处获取输入,并在第二页的文本框中显示相应的文本,正像上面的网络服务要根据用户的输入来引用(播放)一样。这些事情必须在单击第一页的按钮时发生。

< 加强> NOTE: - 我试过了。 它正在运行 。 但是它唯一在第二页 上显示的空白页面

如何实现这一概念?

请找到我的代号参考

<强度>WebService 后端等级 [DYNAMIC项目]

public class GetStudentInformation {
    public String GetStudentInformation(String str){
        return(str);
    }
}

< 坚固 > Android java 类第1页

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button next = (Button) findViewById(R.id.btn);
        next.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent myIntent = new Intent(view.getContext(), Web_concept.class);
                startActivityForResult(myIntent, 0);
            }

        });
    }
}

<强度 > Anddroid java 类第2页

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main1);

            try
            {
                SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
                EditText num1 = (EditText) findViewById(R.id.editT);
                request.addProperty("str", Integer.valueOf(num1.getText().toString()));
                SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                envelope.dotNet = true;
                envelope.setOutputSoapObject(request);
                HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
                androidHttpTransport.call(SOAP_ACTION,envelope);
                Object result = envelope.getResponse();
                System.out.println("Result : " + result.toString());
                ((TextView) findViewById (R.id.textView1)).setText(result.toString());
                } 
            catch (Exception E) {
                    E.printStackTrace();
                }
            }
       }

谢谢你的帮助!

最佳回答

First thing change your input to web service as define in web service method i.e change the line request.addProperty("str", Integer.valueOf(num1.getText().toString()));

to request.addProperty("str", num1.getText().toString()); as you define str as String in your webmethod

and second thing change Object result = envelope.getResponse();

to Object result = envelope.bodyIn;

and please check on Internet how to access textView of second page in first page. I am not sure about it.may be it is not possible.

问题回答

暂无回答




相关问题
In Eclipse, why doesn t "Show In" appear for non-Java files?

If I have a *java file open, I can right click on the source, scroll down to "Show In (Alt-Shift-W)", and select Navigator. If I have an *xml, *jsp, or pretty much anything besides a Java source ...

Eclipse: Hover broken in debug perspective

Since upgrading Eclipse (Galileo build 20090920-1017), hover in debug no longer displays a variable s value. Instead, hover behaves as if I were in normal Java perspective: alt text http://...

Eclipse smart quotes - like in Textmate

Happy Friday — Does anyone know if eclipse has the notion of smart quotes like Textmate. The way it works is to select some words and quote them by simply hitting the " key? I m a newbie here so be ...

Indentation guide for the eclipse editor

Is there a setting or plugin for eclipse that can show indentation guides in the editor? Something like the Codekana plugin for visual studio (not so fancy is also OK). Important that it works with ...

Adding jar from Eclipse plugin runtime tab

I want to add .jar files for plugin from the Runtime tab of manifest file. When I use the Add... button, I can see only sub-directories of the plugin project. So if I want to add same .jar file to ...

How to copy multiple projects into single folder in eclipse

I have two projects, Project1 and Project2. Now i want to copy this projects into eclipse workspace but i want these projects to be in a single folder like below. Eclipse Workspace -> Project -> ...

Java: Finding out what is using all the memory

I have a java application that runs out of memory, but I have no idea which code is allocating the memory. Is there an application with which I can check this? I use Eclipse.