Hai,
I am a beginer in the fied of android.I just trying to develop an
application.Now my problem is that i want to see the datas collected
from the data base using websevice SOAP method as ListView .Now it is
in TextVew. Please somebody help me..
Thanks in advance..
Here is my code:
package grid.test;
import java.util.Vector;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import grid.test.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.view.*;
import android.widget.TextView;
public class screen2 extends Activity
{
/** Called when the activity is first created. */
private static final String SOAP_ACTION = "getMessage";
private static final String METHOD_NAME = "getMessage";
private static final String NAMESPACE = "";
// !!!!! IMPORTANT!!!!! THE URL OF THE CoLDFUSION WEBSERVER NOT
LOCALHOST BECAUSE LOCALHOST IS THE ANDROID EMULATOR !!!!!
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.screen2);
Bundle extras = getIntent().getExtras();
TextView tv = new TextView(this);
tv.setText(extras.getString("keyName"));
TextView mytitletext = (TextView) findViewById(R.id.text);
mytitletext.setText(extras.getString("keyName"));
final String URL = "http://www.bestindiancooking.com/
get_user_submitted_recipes.php?id="+extras.getString("keyName");
//CALL the web service method with the two parameters vname and
nname
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("nname", "Christian");
request.addProperty("itemdescription", "Braun");
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new
AndroidHttpTransport (URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
// Get the SAOP Envelope back and the extract the body
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
Vector XXXX = (Vector)
resultsRequestSOAP.getProperty("getMessageReturn");
//Count of the arrays beneath starting from 0
//You can see the buildup with the php site with nusoap
http://localhost/DA/nusoapclient_test2.php
int testat = XXXX.size();
// It depends on how many arrays we have we can get to the
attributs of one of them with get(0), get(1) ....
Integer i;
String rec_count;
SoapObject test_cnt = (SoapObject) XXXX.get(0);
rec_count= (String) test_cnt.getProperty("ncount");
((TextView)findViewById(R.id.lblStatus)).append(rec_count.toString()
+"\n");
for(i=1;i< 10;i++)
{
SoapObject test = (SoapObject) XXXX.get(i);
String rec_name,preparation_time;
rec_name=(String) test.getProperty("recipe_name");
preparation_time=(String)
test.getProperty("preparation_time");
((TextView)findViewById(R.id.lblStatus)).append(rec_name.toString()
+"\t");
((TextView)findViewById(R.id.lblStatus)).append(preparation_time.toString()
+"\n");
}
} catch(Exception E) {
((TextView)findViewById(R.id.lblStatus)).setText("ERROR:" +
E.getClass().getName() + ": " + E.getMessage()+"error");
}
Button b = (Button) findViewById(R.id.btnClick2);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
setResult(RESULT_OK);
finish();
}
});
}
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en