简体   繁体   English

通过android中的post发送数据

[英]send data via post in android

I am developing my first andoid app and want to post some data to my php webservice. 我正在开发我的第一个Andoid应用程序,并希望将一些数据发布到我的php Web服务。 I have the following signup.xml form 我有以下signup.xml表单

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/signup_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView6"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp"
        android:text="Please Register To Get Started"
        android:textSize="20sp" />

   .
   .    
   .
    <Button
        android:id="@+id/signupbutton"
        style="@android:style/Widget.Material.Button.Borderless"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/phone"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp"
        android:background="@drawable/rg_bg"
        android:text="Signup"
        android:textColor="#ffffff"
        android:textSize="20sp"
        android:onClick="send" />

</RelativeLayout>

This is the corresponding code for the signup.java file 这是signup.java文件的相应代码

package com.example.abhi.myapplication2;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;


public class signup extends ActionBarActivity {

    EditText username,pass,cpass,mail,phn;
    String uname,password,confirmpass,email;
    int phone=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
        username = (EditText)findViewById(R.id.username);
        pass = (EditText)findViewById(R.id.password);
        cpass = (EditText)findViewById(R.id.comfirmpass);
        mail = (EditText)findViewById(R.id.email);
        phn = (EditText)findViewById(R.id.phone);

        Button signup = (Button)findViewById(R.id.signupbutton);

        public void send(View v)
        {
            //Some code will go here
        }

    }   

I am reading tutorials and trying to code now the tutorial says that for the signup button to work I need to create the public void send(View V) but this line throws an error - Cannot Resolve Symbol View 我正在阅读教程并尝试编写代码,该教程说,要使注册按钮正常工作,我需要创建public void send(View V)但此行会引发错误- Cannot Resolve Symbol View

Why is this error coming up, and in the situation above where all I want to do is post some data to my php backend when user clicks on the signup button what should be the correct way of solving this situation? 为什么会出现此错误,并且在上述情况下,当用户单击“ signup button时,我想做的就是将一些数据发布到我的php后端,什么是解决此情况的正确方法?

Try import android.view.View; 尝试import android.view.View;

IDE usually takes care of imports though, are you not using Android Studio or Eclipse? IDE通常会负责导入,但是您不使用Android Studio还是Eclipse?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM