Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 909573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:54:05+00:00 2026-05-15T16:54:05+00:00

I’ve modified my previous code for login. package log1.log2; import android.app.Activity; import android.content.Intent; import

  • 0

I’ve modified my previous code for login.

package log1.log2;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Login extends Activity implements OnClickListener{

    UserDB db = new UserDB(this);
/** Called when the activity is first created. */

    private EditText etUsername;
    private EditText etPassword;
    private Button btnLogin;//private Button btnRegister;
    private TextView lblResult;

    @Override       
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);
     // Get the EditText and Button References
        etUsername = (EditText)findViewById(R.id.usernametxt);
        etPassword = (EditText)findViewById(R.id.passwordtxt);
        btnLogin = (Button)findViewById(R.id.btnLogin);
        //btnRegister = (Button)findViewById(R.id.btnRegister);
        lblResult = (TextView)findViewById(R.id.msglbl);

        //Cursor c = (Cursor) db.getAllTitles();

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

    // Set Click Listener
    btnLogin.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        db.open();
        // Check Login
        String username = etUsername.getText().toString();
        String password = etPassword.getText().toString();
        if(username.equals("")){
            if(password.equals(""))
                onClick();
            else
            {
                lblResult.setText("Wrong password");
            }       
        } else {
            lblResult.setText("Username does not exist. Please register.");
        }           
        db.close();
    }
  });
    }     
    public void onClick(View v)
    {   
        if (v.getId() == R.id.btnLogin) 
        {
            Intent intent = new Intent(this, Test.class);
            startActivity(intent);
        } 
        else
        {
            Intent intent = new Intent(this, Home.class);
            startActivity(intent);
        }               
     }       
}

As you can see, I’ve left a blank on my if..else. I do not know how to apply an sql statement to check the user and password.

if(username.equals("sqlstatement")){
            if(password.equals("sqlstatement"))
                onClick();
            else
            {
                lblResult.setText("Wrong password");
            }    
 } else 
        lblResult.setText("Username does not exist. Please register.");

I’ve insert onClick(); to direct to the other method so that the user will be directed to another page by using the onClickListener method, intent. But I’m having trouble doing that and so I thought that my code is wrong or there should be another way to direct to the other page once the user entered the correct username and password.

Before that, what should I do so that there would be a database connection? Or have I created a connection by inserting db.Open()?

I need to know the codes needed to be inserted the if..else statement.

Another basic stuff I want to know is how to set the text on the password edittext box to dots instead of the actual text.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:54:05+00:00Added an answer on May 15, 2026 at 4:54 pm

    for redirection pleae check my post on this issue
    http://android-pro.blogspot.com/2010/06/android-intents-part-2-passing-data-and.html

    and to set the password TextView please check this

    http://android-pro.blogspot.com/2010/03/android-text-controls.html

    thanks

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.