Re: [android-developers] User Registration using CouchDB
This is the code for registration class, when I click register button nothing happens. Please help so that I can do this.. Take a look at the code you have in the click handler you added (near the beginning) to the button. This click handler is near the bottom of the file: @Override public void onClick(View v) { Button login = (Button) findViewById(R.id.btnRegister); login.setOnClickListener(this); } Notice that all you do here is grab this exact same button, and set the exact same click listener back into it. This is why it appears to do nothing. The actual code that attempts to log in is in the click listener you add to the *TextView*: TextView reg = (TextView) findViewById(R.id.link_to_login); reg.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { etc. Not sure why you added a click listener to the TextView - it appears you may have got a little mixed up about how you want your interface to work. To start with, to try and help make your code a little easier to follow, I recommend two things: 1. Move the code that attempts the login from the body of the click listener you added to the TextView into a separate method of the class, called doLogin() or something similar. For now, don't add the click listener to the TextView - you can sort out that additional functionality later. 2. Don't make the RegisterActivity implement ClickListener - instead, be consistent and add an anonymous click listener to the button (to replace the one you add at the moment at the start of onCreate() ). From that onClick() method, get it to attempt the login (and yes, I deliberately didn't specify exactly how, to give you a chance to examine the revised code and try and work it out for yourself). See if you can repair your code from that. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] User Registration using CouchDB
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: >> > 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" > >> >> >> >> > android:layout_width="fill_parent" >> android:layout_height="wrap_content" >> android:text="@string/fname" >> android:textColor="#372c24" /> >> >> > 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" /> >> >> >> >> > android:layout_width="fill_parent" >> android:layout_height="wrap_content" >> android:text="@string/email" >> android:textColor="#372c24" /> >> >> > 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" /> >> >> >> > android:layout_width="fill_parent" >> android:layout_height="wrap_content" >> android:text="@string/pass" >> android
Re: [android-developers] User Registration using CouchDB
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: > 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" > > > > > android:layout_width="fill_parent" > android:layout_height="wrap_content" > android:text="@string/fname" > android:textColor="#372c24" /> > > 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" /> > > > > android:layout_width="fill_parent" > android:layout_height="wrap_content" > android:text="@string/email" > android:textColor="#372c24" /> > > 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" /> > > > android:layout_width="fill_parent" > android:layout_height="wrap_content" > android:text="@string/pass" > android:textColor="#372c24" /> > > android:layout_width="fill_parent" > android:layout_height="wrap_content" > android:layout_marginTop="5dip" > android:hint="@string/phint" > android:password="true" > android:singleLine="true" /> > > > android:id="@+id/btnRegister" > android:layout_width="fill_parent" > android:layout_height="wrap_content" > android:layout_marginTop="10dip" > android:text="@string/login" /> > > 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 android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] User Registration using CouchDB
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: 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" > 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en