Android 我的HttpPost don';不要发送数据。怎么了?

Android 我的HttpPost don';不要发送数据。怎么了?,android,Android,我正在制作一个新的HttpPost应用程序,但它不会将数据发送到网页post.php 我做错了什么? 我的代码有什么问题 MainActivity.java package com.pixelayer.httppost.httppost; 导入java.io.IOException; 导入java.util.ArrayList; 导入java.util.List; 导入org.apache.http.HttpResponse; 导入org.apache.http.NameValuePair; 导

我正在制作一个新的HttpPost应用程序,但它不会将数据发送到网页post.php

我做错了什么?
我的代码有什么问题

MainActivity.java

package com.pixelayer.httppost.httppost;
导入java.io.IOException;
导入java.util.ArrayList;
导入java.util.List;
导入org.apache.http.HttpResponse;
导入org.apache.http.NameValuePair;
导入org.apache.http.client.ClientProtocolException;
导入org.apache.http.client.HttpClient;
导入org.apache.http.client.entity.UrlEncodedFormEntity;
导入org.apache.http.client.methods.HttpPost;
导入org.apache.http.impl.client.DefaultHttpClient;
导入org.apache.http.message.BasicNameValuePair;
导入android.app.Activity;
导入android.opengl.Visibility;
导入android.os.AsyncTask;
导入android.support.v7.app.ActionBarActivity;
导入android.os.Bundle;
导入android.view.Menu;
导入android.view.MenuItem;
导入android.view.view;
导入android.view.view.OnClickListener;
导入android.widget.Button;
导入android.widget.EditText;
导入android.widget.ProgressBar;
导入android.widget.TextView;
导入android.widget.Toast;
公共类MainActivity扩展活动实现OnClickListener{
私有文本值;
专用按钮btn;
私人ProgressBar pb;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
值=(EditText)findViewById(R.id.editText1);
btn=(按钮)findViewById(R.id.button1);
pb=(ProgressBar)findViewById(R.id.progressBar1);
pb.setVisibility(View.GONE);
btn.setOnClickListener(此);
}
@凌驾
公共布尔onCreateOptions菜单(菜单){
//为菜单充气;这会将项目添加到操作栏(如果存在)。
getMenuInflater().充气(右菜单菜单菜单主菜单);
返回true;
}
公共void onClick(视图v){
//TODO自动生成的方法存根
if(value.getText().toString().length())
此行很可能引发异常,而您正在忽略所有异常。请尝试通过adb记录它们,如下所示:

    try {
       //...
    } catch (ClientProtocolException e) {
        Log.d("MYAPP", e.getMessage(), e);
    } catch (IOException e) {
        Log.d("MYAPP", e.getMessage(), e);
    }

我用上面的代码更改了我的代码,但它没有将数据发送到我的网页。我的代码有什么问题?请告诉我。你需要查看日志消息-它会准确地告诉你有什么问题。你的代码是正确的,但有很多外部变量说明它不起作用的原因,我不可能告诉你答案。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"   android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:text="Enter Something Below:"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<EditText
    android:id="@+id/editText1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="30dp"
    android:ems="10"
    android:hint=""
    >

    <requestFocus />
</EditText>

<ProgressBar
    android:id="@+id/progressBar1"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/editText1"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="24dp" />

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_alignRight="@+id/editText1"
    android:layout_below="@+id/progressBar1"
    android:layout_marginTop="24dp"
    android:text="Submit" />

</RelativeLayout>
HttpResponse response = httpclient.execute(httppost);
    try {
       //...
    } catch (ClientProtocolException e) {
        Log.d("MYAPP", e.getMessage(), e);
    } catch (IOException e) {
        Log.d("MYAPP", e.getMessage(), e);
    }