开发学院手机开发Android 开发 Android的HTTP通信 XML解析和异步消息处理 阅读

Android的HTTP通信 XML解析和异步消息处理

 2010-02-03 19:10:00 来源:WEB开发网   
核心提示:import org.apache.http.client.methods.HttpPost;import org.apache.http.impl.client.DefaultHttpClient;import org.apache.http.message.BasicNameValuePair;import org

import org.apache.http.client.methods.HttpPost;

import org.apache.http.impl.client.DefaultHttpClient;

import org.apache.http.message.BasicNameValuePair;

import org.apache.http.protocol.HTTP;

import org.apache.http.util.ByteArrayBuffer;

import org.apache.http.util.EncodingUtils;

import org.w3c.dom.Document;

import org.w3c.dom.Element;

import org.w3c.dom.NodeList;

import org.xml.sax.InputSource;

import org.xml.sax.XMLReader;

import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.TextView;

public class Main extends Activity {

private TextView textView;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

textView = (TextView) this.findViewById(R.id.textView);

Button btn1 = (Button) this.findViewById(R.id.btn1);

btn1.setText("http get demo");

btn1.setOnClickListener(new Button.OnClickListener() {

public void onClick(View v) {

httpGetDemo();

}

});

Button btn2 = (Button) this.findViewById(R.id.btn2);

btn2.setText("http post demo");

btn2.setOnClickListener(new Button.OnClickListener() {

public void onClick(View v) {

httpPostDemo();

}

});

Button btn3 = (Button) this.findViewById(R.id.btn3);

// DOM - Document Object Model

btn3.setText("DOM 解析 XML");

btn3.setOnClickListener(new Button.OnClickListener() {

public void onClick(View v) {

DOMDemo();

}

上一页  1 2 3 4 5 6 7 8  下一页

Tags:Android HTTP 通信

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接