1、1、创建项目新建一个Android工程,目录结构如下图:2、添加布局文件修改main.xml布局文件,如下LinearLayout xmlns:android= android:orientation=verticallayout_width=fill_parentlayout_height= LinearLayout android: android:+id/linearLayout3 +id/linearLayout2+id/textView1取值+id/editText32556800654 +id/linearLayout1Button android:+id/Button1 andr
2、oid:get+id/Button2post /ScrollView3、创建Activitypublic class slide8_3 extends Activity public String myhttpget(String url) throws Exception String out = null;try HttpClient client = new DefaultHttpClient();HttpGet request = new HttpGet(url);HttpResponse response = client.execute(request);out = EntityU
3、tils.toString(response.getEntity(); catch (IOException e) e.printStackTrace();return out;public String myhttppost(String url, String name, String value)throws Exception HttpPost request = new HttpPost(url);List postParameters = new ArrayList();postParameters.add(new BasicNameValuePair(name, value);U
4、rlEncodedFormEntity formEntity = new UrlEncodedFormEntity(postParameters);request.setEntity(formEntity);Overridepublic void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState);setContentView(R.layout.main);final TextView textView = (TextView) findViewById(R.id.TextView01);final Ed
5、itText editText = (EditText) findViewById(R.id.editText1);final EditText name = (EditText) findViewById(R.id.editText2);final EditText value = (EditText) findViewById(R.id.editText3);Button btn = (Button) this.findViewById(R.id.Button1);btn.setOnClickListener(new Button.OnClickListener() public void onClick(View v) try textView.setText(myhttpget(editText.getText().toString()+ + name.getText().toString() + =+ value.getText().toString(); catch (Exception e) e.printStackTrace(););Button btn2 = (Button) this.findViewById(R.id.Button2);btn2.setOnClickListener(new Button.OnClick
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1