从Android的Eclipse中使用的EditText和按钮使用Web服务按钮、Eclipse、Android、Web

2023-09-13 01:18:40 作者:余温散尽 ぺ

我自精简到android.Right现在我的方法的 SOAP消耗在Android的日食Web服务。所以我已经创建了两个pages.The第一页是由一个EditText和一个按钮而第二页只由一个textbox.I正在创建完全一样的web服务的 GetBibleWordsbyKeyWord 在Android的月食。

i am self-leaner to android.Right now i am consuming web service in android eclipse by the method SOAP.So i have created two pages.The first page consists of an edittext and a button and the second page consists of only one textbox.I am creating exactly like this webservice GetBibleWordsbyKeyWord in android eclipse.

下面我的需要是获得来自用户的输入通过的EditText框1页,并显示在第二页的文本框中适当的文本正是上述Web服务是根据用户的input.These东西去调用(显示器)必须想在第一页单击按钮时发生。

Here my need is to get the input from the user by edittext box on page one and display appropriate texts on second page's textbox exactly what the above web service is going to invoke(display)according to the user's input.These things must want to be happen when clicking the button from the page one.

注: - 我已经试过it.Its越来越run.But其唯一显示两个页面上的空白页的

怎么做才能达到这个概念?

What to do to achieve this concept?

请找我的code仅供参考

Please find my code for reference

web服务后端类【项目动态】

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);
            }

        });
    }
}

Android的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();
                }
            }
       }

感谢您的帮助!

Thanks for any help!

推荐答案

第一件事,改变你输入的Web服务定义为在Web服务方法 即改变行 request.addProperty(海峡,Integer.valueOf(num1.getText()的toString()));

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()));

request.addProperty(海峡,num1.getText()的toString()); 当你定义 STR 为字符串在 的WebMethod

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

和第二件事改变对象result = envelope.getResponse();

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

对象result = envelope.bodyIn;

to Object result = envelope.bodyIn;

和请在第一页的互联网第二页如何访问的TextView 。 我不知道it.may无论是不可能的。

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.