我在我的应用中制作了这段代码:
np.array_equal
这是我在服务器post.php上的代码
public class human_Adding_Items extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_human__adding__items);
final EditText humanButtonadd1 = (EditText) findViewById(R.id.imageButton1);
final EditText humanButtonadd2 = (EditText) findViewById(R.id.imageButton2);
final Button humanButtonadd3 = (Button) findViewById(R.id.imageButton3);
final Button humanButtonadd4 = (Button) findViewById(R.id.imageButton4);
final Button humanButtonadd5 = (Button) findViewById(R.id.imageButton5);
final Button humanButtonadd6 = (Button) findViewById(R.id.imageButton6);
humanButtonadd3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
humanButtonadd3.setBackgroundResource(R.mipmap.item_button);
humanButtonadd4.setVisibility(View.VISIBLE);
}
});
humanButtonadd4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
humanButtonadd4.setBackgroundResource(R.mipmap.item_button);
humanButtonadd5.setVisibility(View.VISIBLE);
}
});
humanButtonadd5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
humanButtonadd5.setBackgroundResource(R.mipmap.item_button);
humanButtonadd6.setVisibility(View.VISIBLE);
}
});
humanButtonadd6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
humanButtonadd6.setBackgroundResource(R.mipmap.item_button);
}
});
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+1:00"));
final Date currentLocalTime = cal.getTime();
final DateFormat date = new SimpleDateFormat("HH:mm a");
date.setTimeZone(TimeZone.getTimeZone("GMT+1:00"));
final String localTime = date.format(currentLocalTime);
final Button b = (Button) findViewById(R.id.ConfirmButtton);
b.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
final String url = "http://192.168.43.27/app_site/api/post.php";
StringRequest sq = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}) {
protected Map<String, String> getParams(){
Map<String, String> parr = new HashMap<String, String>();
parr.put("text1", humanButtonadd1.getText().toString() );
parr.put("text2", humanButtonadd2.getText().toString() );
return parr;
}
};
}
});
}
我尝试将应用程序中的文本数据发送到服务器,但它没有发生...... :( 我不明白为什么?! 你可以帮我吗? btw last file post.php显示以下错误:
注意:未定义的索引:text1 in 第13行的C:\ xampp \ htdocs \ app_site \ api \ post.php
注意:未定义索引:text2 in 第14行的C:\ xampp \ htdocs \ app_site \ api \ post.php
但它在刷新页面上的数据库中插入text1和text2 P.S即时使用本地服务器“xampp”,也许这就是问题?