Android: How to use a card view instead of a button
up vote
0
down vote
favorite
I have a dialog which currently opens on a button click and works fine but it means I have an ugly button that does not look good, I would prefer it to be opened from a CardView
.
This is the card view:
CardView manager=findViewById(R.id.manager_card);
manager.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
);
And this is the dialog which currently opens from a button click:
Button btnLoginDialog;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_in);
// Init Widget Button and set click listener
btnLoginDialog = (Button) findViewById(R.id.btnLoginDialog);
btnLoginDialog.setOnClickListener(this);
@Override
public void onClick(View v)
if (v == btnLoginDialog)
// Create Object of Dialog class
final Dialog login = new Dialog(this);
// Set GUI of login screen
login.setContentView(R.layout.login_gui);
login.setTitle("Login to Pulse 7");
// Init button of login GUI
Button btnLogin = (Button) login.findViewById(R.id.btnLogin);
Button btnCancel = (Button) login.findViewById(R.id.btnCancel);
final EditText txtUsername = (EditText)login.findViewById(R.id.txtUsername);
final EditText txtPassword = (EditText)login.findViewById(R.id.txtPassword);
// Attached listener for login GUI button
btnLogin.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
if(txtUsername.getText().toString().trim().equals("admin") && txtPassword.getText().toString().trim().equals("admin"))
// Validate Your login credential here than display message
Toast.makeText(SignInActivity.this,
"Login Sucessfull", Toast.LENGTH_LONG).show();
// Redirect to dashboard / home screen.
login.dismiss();
Intent intent = new Intent(getApplicationContext(), ManagerMenu.class);
startActivity(intent);
else
Toast.makeText(SignInActivity.this,
"Please enter valid Username and Password", Toast.LENGTH_LONG).show();
);
btnCancel.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
login.dismiss();
);
// Make dialog box visible.
login.show();
I can't figure this out. I hope there is enough information there for someone to help me out.
java android
add a comment |
up vote
0
down vote
favorite
I have a dialog which currently opens on a button click and works fine but it means I have an ugly button that does not look good, I would prefer it to be opened from a CardView
.
This is the card view:
CardView manager=findViewById(R.id.manager_card);
manager.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
);
And this is the dialog which currently opens from a button click:
Button btnLoginDialog;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_in);
// Init Widget Button and set click listener
btnLoginDialog = (Button) findViewById(R.id.btnLoginDialog);
btnLoginDialog.setOnClickListener(this);
@Override
public void onClick(View v)
if (v == btnLoginDialog)
// Create Object of Dialog class
final Dialog login = new Dialog(this);
// Set GUI of login screen
login.setContentView(R.layout.login_gui);
login.setTitle("Login to Pulse 7");
// Init button of login GUI
Button btnLogin = (Button) login.findViewById(R.id.btnLogin);
Button btnCancel = (Button) login.findViewById(R.id.btnCancel);
final EditText txtUsername = (EditText)login.findViewById(R.id.txtUsername);
final EditText txtPassword = (EditText)login.findViewById(R.id.txtPassword);
// Attached listener for login GUI button
btnLogin.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
if(txtUsername.getText().toString().trim().equals("admin") && txtPassword.getText().toString().trim().equals("admin"))
// Validate Your login credential here than display message
Toast.makeText(SignInActivity.this,
"Login Sucessfull", Toast.LENGTH_LONG).show();
// Redirect to dashboard / home screen.
login.dismiss();
Intent intent = new Intent(getApplicationContext(), ManagerMenu.class);
startActivity(intent);
else
Toast.makeText(SignInActivity.this,
"Please enter valid Username and Password", Toast.LENGTH_LONG).show();
);
btnCancel.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
login.dismiss();
);
// Make dialog box visible.
login.show();
I can't figure this out. I hope there is enough information there for someone to help me out.
java android
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a dialog which currently opens on a button click and works fine but it means I have an ugly button that does not look good, I would prefer it to be opened from a CardView
.
This is the card view:
CardView manager=findViewById(R.id.manager_card);
manager.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
);
And this is the dialog which currently opens from a button click:
Button btnLoginDialog;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_in);
// Init Widget Button and set click listener
btnLoginDialog = (Button) findViewById(R.id.btnLoginDialog);
btnLoginDialog.setOnClickListener(this);
@Override
public void onClick(View v)
if (v == btnLoginDialog)
// Create Object of Dialog class
final Dialog login = new Dialog(this);
// Set GUI of login screen
login.setContentView(R.layout.login_gui);
login.setTitle("Login to Pulse 7");
// Init button of login GUI
Button btnLogin = (Button) login.findViewById(R.id.btnLogin);
Button btnCancel = (Button) login.findViewById(R.id.btnCancel);
final EditText txtUsername = (EditText)login.findViewById(R.id.txtUsername);
final EditText txtPassword = (EditText)login.findViewById(R.id.txtPassword);
// Attached listener for login GUI button
btnLogin.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
if(txtUsername.getText().toString().trim().equals("admin") && txtPassword.getText().toString().trim().equals("admin"))
// Validate Your login credential here than display message
Toast.makeText(SignInActivity.this,
"Login Sucessfull", Toast.LENGTH_LONG).show();
// Redirect to dashboard / home screen.
login.dismiss();
Intent intent = new Intent(getApplicationContext(), ManagerMenu.class);
startActivity(intent);
else
Toast.makeText(SignInActivity.this,
"Please enter valid Username and Password", Toast.LENGTH_LONG).show();
);
btnCancel.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
login.dismiss();
);
// Make dialog box visible.
login.show();
I can't figure this out. I hope there is enough information there for someone to help me out.
java android
I have a dialog which currently opens on a button click and works fine but it means I have an ugly button that does not look good, I would prefer it to be opened from a CardView
.
This is the card view:
CardView manager=findViewById(R.id.manager_card);
manager.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
);
And this is the dialog which currently opens from a button click:
Button btnLoginDialog;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_in);
// Init Widget Button and set click listener
btnLoginDialog = (Button) findViewById(R.id.btnLoginDialog);
btnLoginDialog.setOnClickListener(this);
@Override
public void onClick(View v)
if (v == btnLoginDialog)
// Create Object of Dialog class
final Dialog login = new Dialog(this);
// Set GUI of login screen
login.setContentView(R.layout.login_gui);
login.setTitle("Login to Pulse 7");
// Init button of login GUI
Button btnLogin = (Button) login.findViewById(R.id.btnLogin);
Button btnCancel = (Button) login.findViewById(R.id.btnCancel);
final EditText txtUsername = (EditText)login.findViewById(R.id.txtUsername);
final EditText txtPassword = (EditText)login.findViewById(R.id.txtPassword);
// Attached listener for login GUI button
btnLogin.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
if(txtUsername.getText().toString().trim().equals("admin") && txtPassword.getText().toString().trim().equals("admin"))
// Validate Your login credential here than display message
Toast.makeText(SignInActivity.this,
"Login Sucessfull", Toast.LENGTH_LONG).show();
// Redirect to dashboard / home screen.
login.dismiss();
Intent intent = new Intent(getApplicationContext(), ManagerMenu.class);
startActivity(intent);
else
Toast.makeText(SignInActivity.this,
"Please enter valid Username and Password", Toast.LENGTH_LONG).show();
);
btnCancel.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
login.dismiss();
);
// Make dialog box visible.
login.show();
I can't figure this out. I hope there is enough information there for someone to help me out.
java android
java android
edited Nov 11 at 12:54
DudeCoder
1,234323
1,234323
asked Nov 11 at 11:27
Haeata Mikaere
82
82
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
Use this type,this will help you:-
CardView manager=findViewById(R.id.manager_card);
manager.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
final Dialog login = new Dialog(this);
// Set GUI of login screen
login.setContentView(R.layout.login_gui);
login.setTitle("Login to Pulse 7");
// Init button of login GUI
Button btnLogin = (Button) login.findViewById(R.id.btnLogin);
Button btnCancel = (Button) login.findViewById(R.id.btnCancel);
final EditText txtUsername = (EditText)login.findViewById(R.id.txtUsername);
final EditText txtPassword = (EditText)login.findViewById(R.id.txtPassword);
// Attached listener for login GUI button
btnLogin.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
if(txtUsername.getText().toString().trim().equals("admin") && txtPassword.getText().toString().trim().equals("admin"))
// Validate Your login credential here than display message
Toast.makeText(SignInActivity.this,
"Login Sucessfull", Toast.LENGTH_LONG).show();
// Redirect to dashboard / home screen.
login.dismiss();
Intent intent = new Intent(getApplicationContext(), ManagerMenu.class);
startActivity(intent);
else
Toast.makeText(SignInActivity.this,
"Please enter valid Username and Password", Toast.LENGTH_LONG).show();
);
btnCancel.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
login.dismiss();
);
// Make dialog box visible.
login.show();
);
Thanks that worked perfectly. I just could not figure it out.
– Haeata Mikaere
Nov 11 at 12:10
add a comment |
up vote
0
down vote
Setting up OnClickListener
on any Button
and on any CardView
is the exact same, in fact, setting OnClickListener
on any class object which is a child class of View
is exact same.
That being said, just replace with OnClick
code of Button
with the OnClick
code of CardView
and that will work the same, like so:
CardView manager=findViewById(R.id.manager_card);
manager.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
// Create Object of Dialog class
final Dialog login = new Dialog(this);
// Set GUI of login screen
login.setContentView(R.layout.login_gui);
login.setTitle("Login to Pulse 7");
// Init button of login GUI
Button btnLogin = (Button) login.findViewById(R.id.btnLogin);
Button btnCancel = (Button) login.findViewById(R.id.btnCancel);
final EditText txtUsername = (EditText)login.findViewById(R.id.txtUsername);
final EditText txtPassword = (EditText)login.findViewById(R.id.txtPassword);
// Attached listener for login GUI button
btnLogin.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
if(txtUsername.getText().toString().trim().equals("admin") && txtPassword.getText().toString().trim().equals("admin"))
// Validate Your login credential here than display message
Toast.makeText(SignInActivity.this,
"Login Sucessfull", Toast.LENGTH_LONG).show();
// Redirect to dashboard / home screen.
login.dismiss();
Intent intent = new Intent(getApplicationContext(), ManagerMenu.class);
startActivity(intent);
else
Toast.makeText(SignInActivity.this,
"Please enter valid Username and Password", Toast.LENGTH_LONG).show();
);
btnCancel.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
login.dismiss();
);
// Make dialog box visible.
login.show();
);
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Use this type,this will help you:-
CardView manager=findViewById(R.id.manager_card);
manager.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
final Dialog login = new Dialog(this);
// Set GUI of login screen
login.setContentView(R.layout.login_gui);
login.setTitle("Login to Pulse 7");
// Init button of login GUI
Button btnLogin = (Button) login.findViewById(R.id.btnLogin);
Button btnCancel = (Button) login.findViewById(R.id.btnCancel);
final EditText txtUsername = (EditText)login.findViewById(R.id.txtUsername);
final EditText txtPassword = (EditText)login.findViewById(R.id.txtPassword);
// Attached listener for login GUI button
btnLogin.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
if(txtUsername.getText().toString().trim().equals("admin") && txtPassword.getText().toString().trim().equals("admin"))
// Validate Your login credential here than display message
Toast.makeText(SignInActivity.this,
"Login Sucessfull", Toast.LENGTH_LONG).show();
// Redirect to dashboard / home screen.
login.dismiss();
Intent intent = new Intent(getApplicationContext(), ManagerMenu.class);
startActivity(intent);
else
Toast.makeText(SignInActivity.this,
"Please enter valid Username and Password", Toast.LENGTH_LONG).show();
);
btnCancel.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
login.dismiss();
);
// Make dialog box visible.
login.show();
);
Thanks that worked perfectly. I just could not figure it out.
– Haeata Mikaere
Nov 11 at 12:10
add a comment |
up vote
0
down vote
accepted
Use this type,this will help you:-
CardView manager=findViewById(R.id.manager_card);
manager.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
final Dialog login = new Dialog(this);
// Set GUI of login screen
login.setContentView(R.layout.login_gui);
login.setTitle("Login to Pulse 7");
// Init button of login GUI
Button btnLogin = (Button) login.findViewById(R.id.btnLogin);
Button btnCancel = (Button) login.findViewById(R.id.btnCancel);
final EditText txtUsername = (EditText)login.findViewById(R.id.txtUsername);
final EditText txtPassword = (EditText)login.findViewById(R.id.txtPassword);
// Attached listener for login GUI button
btnLogin.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
if(txtUsername.getText().toString().trim().equals("admin") && txtPassword.getText().toString().trim().equals("admin"))
// Validate Your login credential here than display message
Toast.makeText(SignInActivity.this,
"Login Sucessfull", Toast.LENGTH_LONG).show();
// Redirect to dashboard / home screen.
login.dismiss();
Intent intent = new Intent(getApplicationContext(), ManagerMenu.class);
startActivity(intent);
else
Toast.makeText(SignInActivity.this,
"Please enter valid Username and Password", Toast.LENGTH_LONG).show();
);
btnCancel.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
login.dismiss();
);
// Make dialog box visible.
login.show();
);
Thanks that worked perfectly. I just could not figure it out.
– Haeata Mikaere
Nov 11 at 12:10
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Use this type,this will help you:-
CardView manager=findViewById(R.id.manager_card);
manager.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
final Dialog login = new Dialog(this);
// Set GUI of login screen
login.setContentView(R.layout.login_gui);
login.setTitle("Login to Pulse 7");
// Init button of login GUI
Button btnLogin = (Button) login.findViewById(R.id.btnLogin);
Button btnCancel = (Button) login.findViewById(R.id.btnCancel);
final EditText txtUsername = (EditText)login.findViewById(R.id.txtUsername);
final EditText txtPassword = (EditText)login.findViewById(R.id.txtPassword);
// Attached listener for login GUI button
btnLogin.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
if(txtUsername.getText().toString().trim().equals("admin") && txtPassword.getText().toString().trim().equals("admin"))
// Validate Your login credential here than display message
Toast.makeText(SignInActivity.this,
"Login Sucessfull", Toast.LENGTH_LONG).show();
// Redirect to dashboard / home screen.
login.dismiss();
Intent intent = new Intent(getApplicationContext(), ManagerMenu.class);
startActivity(intent);
else
Toast.makeText(SignInActivity.this,
"Please enter valid Username and Password", Toast.LENGTH_LONG).show();
);
btnCancel.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
login.dismiss();
);
// Make dialog box visible.
login.show();
);
Use this type,this will help you:-
CardView manager=findViewById(R.id.manager_card);
manager.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
final Dialog login = new Dialog(this);
// Set GUI of login screen
login.setContentView(R.layout.login_gui);
login.setTitle("Login to Pulse 7");
// Init button of login GUI
Button btnLogin = (Button) login.findViewById(R.id.btnLogin);
Button btnCancel = (Button) login.findViewById(R.id.btnCancel);
final EditText txtUsername = (EditText)login.findViewById(R.id.txtUsername);
final EditText txtPassword = (EditText)login.findViewById(R.id.txtPassword);
// Attached listener for login GUI button
btnLogin.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
if(txtUsername.getText().toString().trim().equals("admin") && txtPassword.getText().toString().trim().equals("admin"))
// Validate Your login credential here than display message
Toast.makeText(SignInActivity.this,
"Login Sucessfull", Toast.LENGTH_LONG).show();
// Redirect to dashboard / home screen.
login.dismiss();
Intent intent = new Intent(getApplicationContext(), ManagerMenu.class);
startActivity(intent);
else
Toast.makeText(SignInActivity.this,
"Please enter valid Username and Password", Toast.LENGTH_LONG).show();
);
btnCancel.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
login.dismiss();
);
// Make dialog box visible.
login.show();
);
answered Nov 11 at 11:35
Vishal Sharma
7702212
7702212
Thanks that worked perfectly. I just could not figure it out.
– Haeata Mikaere
Nov 11 at 12:10
add a comment |
Thanks that worked perfectly. I just could not figure it out.
– Haeata Mikaere
Nov 11 at 12:10
Thanks that worked perfectly. I just could not figure it out.
– Haeata Mikaere
Nov 11 at 12:10
Thanks that worked perfectly. I just could not figure it out.
– Haeata Mikaere
Nov 11 at 12:10
add a comment |
up vote
0
down vote
Setting up OnClickListener
on any Button
and on any CardView
is the exact same, in fact, setting OnClickListener
on any class object which is a child class of View
is exact same.
That being said, just replace with OnClick
code of Button
with the OnClick
code of CardView
and that will work the same, like so:
CardView manager=findViewById(R.id.manager_card);
manager.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
// Create Object of Dialog class
final Dialog login = new Dialog(this);
// Set GUI of login screen
login.setContentView(R.layout.login_gui);
login.setTitle("Login to Pulse 7");
// Init button of login GUI
Button btnLogin = (Button) login.findViewById(R.id.btnLogin);
Button btnCancel = (Button) login.findViewById(R.id.btnCancel);
final EditText txtUsername = (EditText)login.findViewById(R.id.txtUsername);
final EditText txtPassword = (EditText)login.findViewById(R.id.txtPassword);
// Attached listener for login GUI button
btnLogin.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
if(txtUsername.getText().toString().trim().equals("admin") && txtPassword.getText().toString().trim().equals("admin"))
// Validate Your login credential here than display message
Toast.makeText(SignInActivity.this,
"Login Sucessfull", Toast.LENGTH_LONG).show();
// Redirect to dashboard / home screen.
login.dismiss();
Intent intent = new Intent(getApplicationContext(), ManagerMenu.class);
startActivity(intent);
else
Toast.makeText(SignInActivity.this,
"Please enter valid Username and Password", Toast.LENGTH_LONG).show();
);
btnCancel.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
login.dismiss();
);
// Make dialog box visible.
login.show();
);
add a comment |
up vote
0
down vote
Setting up OnClickListener
on any Button
and on any CardView
is the exact same, in fact, setting OnClickListener
on any class object which is a child class of View
is exact same.
That being said, just replace with OnClick
code of Button
with the OnClick
code of CardView
and that will work the same, like so:
CardView manager=findViewById(R.id.manager_card);
manager.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
// Create Object of Dialog class
final Dialog login = new Dialog(this);
// Set GUI of login screen
login.setContentView(R.layout.login_gui);
login.setTitle("Login to Pulse 7");
// Init button of login GUI
Button btnLogin = (Button) login.findViewById(R.id.btnLogin);
Button btnCancel = (Button) login.findViewById(R.id.btnCancel);
final EditText txtUsername = (EditText)login.findViewById(R.id.txtUsername);
final EditText txtPassword = (EditText)login.findViewById(R.id.txtPassword);
// Attached listener for login GUI button
btnLogin.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
if(txtUsername.getText().toString().trim().equals("admin") && txtPassword.getText().toString().trim().equals("admin"))
// Validate Your login credential here than display message
Toast.makeText(SignInActivity.this,
"Login Sucessfull", Toast.LENGTH_LONG).show();
// Redirect to dashboard / home screen.
login.dismiss();
Intent intent = new Intent(getApplicationContext(), ManagerMenu.class);
startActivity(intent);
else
Toast.makeText(SignInActivity.this,
"Please enter valid Username and Password", Toast.LENGTH_LONG).show();
);
btnCancel.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
login.dismiss();
);
// Make dialog box visible.
login.show();
);
add a comment |
up vote
0
down vote
up vote
0
down vote
Setting up OnClickListener
on any Button
and on any CardView
is the exact same, in fact, setting OnClickListener
on any class object which is a child class of View
is exact same.
That being said, just replace with OnClick
code of Button
with the OnClick
code of CardView
and that will work the same, like so:
CardView manager=findViewById(R.id.manager_card);
manager.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
// Create Object of Dialog class
final Dialog login = new Dialog(this);
// Set GUI of login screen
login.setContentView(R.layout.login_gui);
login.setTitle("Login to Pulse 7");
// Init button of login GUI
Button btnLogin = (Button) login.findViewById(R.id.btnLogin);
Button btnCancel = (Button) login.findViewById(R.id.btnCancel);
final EditText txtUsername = (EditText)login.findViewById(R.id.txtUsername);
final EditText txtPassword = (EditText)login.findViewById(R.id.txtPassword);
// Attached listener for login GUI button
btnLogin.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
if(txtUsername.getText().toString().trim().equals("admin") && txtPassword.getText().toString().trim().equals("admin"))
// Validate Your login credential here than display message
Toast.makeText(SignInActivity.this,
"Login Sucessfull", Toast.LENGTH_LONG).show();
// Redirect to dashboard / home screen.
login.dismiss();
Intent intent = new Intent(getApplicationContext(), ManagerMenu.class);
startActivity(intent);
else
Toast.makeText(SignInActivity.this,
"Please enter valid Username and Password", Toast.LENGTH_LONG).show();
);
btnCancel.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
login.dismiss();
);
// Make dialog box visible.
login.show();
);
Setting up OnClickListener
on any Button
and on any CardView
is the exact same, in fact, setting OnClickListener
on any class object which is a child class of View
is exact same.
That being said, just replace with OnClick
code of Button
with the OnClick
code of CardView
and that will work the same, like so:
CardView manager=findViewById(R.id.manager_card);
manager.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
// Create Object of Dialog class
final Dialog login = new Dialog(this);
// Set GUI of login screen
login.setContentView(R.layout.login_gui);
login.setTitle("Login to Pulse 7");
// Init button of login GUI
Button btnLogin = (Button) login.findViewById(R.id.btnLogin);
Button btnCancel = (Button) login.findViewById(R.id.btnCancel);
final EditText txtUsername = (EditText)login.findViewById(R.id.txtUsername);
final EditText txtPassword = (EditText)login.findViewById(R.id.txtPassword);
// Attached listener for login GUI button
btnLogin.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
if(txtUsername.getText().toString().trim().equals("admin") && txtPassword.getText().toString().trim().equals("admin"))
// Validate Your login credential here than display message
Toast.makeText(SignInActivity.this,
"Login Sucessfull", Toast.LENGTH_LONG).show();
// Redirect to dashboard / home screen.
login.dismiss();
Intent intent = new Intent(getApplicationContext(), ManagerMenu.class);
startActivity(intent);
else
Toast.makeText(SignInActivity.this,
"Please enter valid Username and Password", Toast.LENGTH_LONG).show();
);
btnCancel.setOnClickListener(new OnClickListener()
@Override
public void onClick(View v)
login.dismiss();
);
// Make dialog box visible.
login.show();
);
answered Nov 11 at 11:49
DudeCoder
1,234323
1,234323
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248259%2fandroid-how-to-use-a-card-view-instead-of-a-button%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown