Thursday, December 16, 2010

how to add view dynamically

Hi All,

Currently I have one activity having 2 EditText box and one Button.
 I want if i will click on the button one more EditText should be added between previous EditText and Button in same Activity.


Can Any One help me in this regard with some code samples.

Thanks.

How to Insert Json To Request and parse the json response data

Hi Guys, 

URL: http://some path/userLogin.html?json=[{"emailid":"vijayajay17@gmail.com","password":"vijay17"}]
o/p: {"login":{"loginmsg":"successful","userid":"20","user_type":"Voter"}}

If I will Run this URL is web browser I should get the above o/p in json format.

in code:

                    JSONObject j = new JSONObject();
                    j.put("emailid", "vijayajay17@gmail.com");
                    j.put("password", "vijay17");                   
                    String url = "http://some path/userLogin.html";
                    HttpClient httpclient = new DefaultHttpClient();
                    HttpPost request = new HttpPost(url);               
                    StringEntity stringEntity = new StringEntity(j.toString());
                    stringEntity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
                    HttpEntity httpEntity = stringEntity;
                    request.setEntity(httpEntity);
                    HttpResponse response = httpclient.execute(request);
                   
                    String temp = EntityUtils.toString(response.getEntity());
                    System.out.println(temp);
                   


         My O/P: {"login":{"loginmsg":"account not activated"}}

Can Any one help me in this?
Where I am doing mistake?

 Thanks in Advance.
.