import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class RegisterActivity extends Activity implements OnClickListener {

private static final int SERVER_PORT = 5984;

private String SERVER_HOST = "127.0.0.1";

public static final String PREFS_NAME = "MydroidPREFS";

private SharedPreferences settings;

private ProgressDialog progress;

public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

settings = getSharedPreferences(PREFS_NAME, 0);
super.onCreate(savedInstanceState);
// requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.register);
Button login = (Button) findViewById(R.id.btnRegister);
login.setOnClickListener(this);
// going back to login page via a textview
TextView reg = (TextView) findViewById(R.id.link_to_login);
reg.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
  Intent i = new Intent(getApplicationContext(),
 LoginActivity.class); startActivity(i);
 EditText usernameEditText = (EditText) findViewById(R.id.txtname);
EditText passwordEditText = (EditText) findViewById(R.id.txtpass);

String sUserName = usernameEditText.getText().toString();
String sPassword = passwordEditText.getText().toString();

String address = "http://"; + SERVER_HOST + ":" + SERVER_PORT+ 
"/database.html?afterdbLogin=" + sUserName + "&Password=" + sPassword + "";

if (usernameEditText == null || passwordEditText == null) {
Context context = getApplicationContext();
CharSequence text = "These fields cannot be empty, please enter Username 
and Password";
int duration = Toast.LENGTH_SHORT;

Toast toast = Toast.makeText(context, text, duration);
toast.show();
} else {

//registration successful

Log.i(DEB_TAG, "Username: " + sUserName + "nPassword: "+ sPassword);

Log.i(DEB_TAG, "Requesting to " + address);
}
}

});

}

@Override
public void onClick(View v) {

Button login = (Button) findViewById(R.id.btnRegister);
login.setOnClickListener(this);

}

public void setUserNameText(String $username) {
EditText usernameEditText = (EditText) findViewById(R.id.txtname);
usernameEditText.setText($username);

}

public void setPasswordText(String $username) {
EditText passwordEditText = (EditText) findViewById(R.id.txtpass);
passwordEditText.setText($username);

}

}

This is the code for registration class, when I click register button 
nothing happens. Please help so that I can do this..

On Wednesday, May 9, 2012 10:42:03 AM UTC+2, sourabh wrote:
>
> Please share full code, otherwise nobody will help you.
>
> On Tue, May 8, 2012 at 2:44 PM, Samboga  wrote:
>
>> I am trying to do a user registration form on Android using CouchDB on 
>> localhost I want to accomplish the basics of a registration which are in my 
>> case FULL NAME, EMAIL AND PASSWORD, I am new to android and I am not sure 
>> how to go about it. I have installed CouchDB on my localhost at port 5984. 
>> my layout file looks like this:
>> <LinearLayout
>>             xmlns:android="http://schemas.android.com/apk/res/android";
>>             android:layout_width="match_parent"
>>             android:layout_height="wrap_content"
>>             android:layout_below="@id/header"
>>             android:orientation="vertical"
>>             android:padding="10dip" >
>>
>>
>>
>>             <TextView
>>                 android:layout_width="fill_parent"
>>                 android:layout_height="wrap_content"
>>                 android:text="@string/fname"
>>                 android:textColor="#372c24" />
>>
>>             <EditText
>>                 android:layout_width="fill_parent"
>>                 android:layout_height="wrap_content"
>>                 android:layout_marginBottom="20dip"
>>                 android:layout_marginTop="5dip"
>>                 android:hint="@string/fnamehint"
>>                 android:singleLine="true" />
>>
>>
>>
>>             <TextView
>>                 android:layout_width="fill_parent"
>>                 android:layout_height="wrap_content"
>>                 android:text="@string/email"
>>                 android:textColor="#372c24" />
>>
>>             <EditText
>>                 android:layout_width="fill_parent"
>>                 android:layout_height="wrap_content"
>>                 android:layout_marginBottom="20dip"
>>                 android:layout_marginTop="5dip"
>>                 android:hint="@string/emailhint"
>>                 android:singleLine="true" />
>>
>>
>>             <TextView
>>                 android:layout_width="fill_parent"
>>                 android:layout_height="wrap_content"
>>                 android:text="@string/pass"
>>                 android:textColor="#372c24" />
>>
>>             <EditText
>>                 android:layout_width="fill_parent"
>>                 android:layout_height="wrap_content"
>>                 android:layout_marginTop="5dip"
>>                 android:hint="@string/phint"
>>                 android:password="true"
>>                 android:singleLine="true" />
>>             <!-- Register button -->
>>
>>             <Button
>>                 android:id="@+id/btnRegister"
>>                 android:layout_width="fill_parent"
>>                 android:layout_height="wrap_content"
>>                 android:layout_marginTop="10dip"
>>                 android:text="@string/login" />
>>             <!-- Link to login Screen -->
>> I also have two classes that will handle the login and user registration, 
>> login.java and register.java , please help me.
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to