现在再做一个project
客户端请求服务器端数据,服务器运行返回数据。
如今客户端可以发到服务器端,但服务器端怎么返回数据啊 试了好几个方法都没有成功的在客户端显示出来!
我服务器端应该返回什么类型的数据啊,现在的可以再log中看到返回的html,怎么显示在页面上啊?
很急,求帮助,最好有例子
------解决方案--------------------
package org.abcd.test;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String htmlStr="{\"username\":\"Kelly\",\"email\":\"[email protected]\",\"telephone\":\"88888888\"}";
TextView tv1 = new TextView(this);
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.HORIZONTAL);
layout.addView(tv1);
addContentView(layout, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
htmlStr = htmlStr.replace("{", "").replace("}", "").replace("\"", "").replace(",", "\n");
tv1.setText(htmlStr);
}
}