Rick Roy
Rick Roy

Reputation: 1728

send data via post in android

I am developing my first andoid app and want to post some data to my php webservice. I have the following signup.xml form

<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

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

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?

Upvotes: 0

Views: 43

Answers (1)

Alexander
Alexander

Reputation: 48232

Try import android.view.View;

IDE usually takes care of imports though, are you not using Android Studio or Eclipse?

Upvotes: 1

Related Questions