你都已经获取服务端返回的数据,现在要做的是你客户端做好显示的界面,例如放一个TextView控件,然后把里面的内容放在TextView显示就好了。你都会用Log的方式查看,就肯定会用TextView吧。

解决方案 »

  1.   

    我的log中得到了下面返回的数据:
    04-18 15:21:08.986: I/System.out(477): [{"username":"Kelly","email":"[email protected]","telephone":"88888888"}]我就是想问一下xml中应该如何写,把这些数据显示在xml界面中?
      

  2.   


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