Issue
I have a bunch of buttons with( the texts inside are date like FRI 12 ) in the screen for user to select. I want to get the text from the selected button to pass it to another activity but still struggle.
I google it for hours and try the code like this
private String date_selected;
public void onClick(View button) {
Button b = (Button)button;
date_selected = b.getText().toString();
Log.d("myTag", date_selected);
Toast.makeText(this,date_selected,Toast.LENGTH_LONG);
}
But it doesn't work. Please help me to solve the problem, I have 3 hours left for my deadline (this is a small homework for my mobile course).
Thank you for your help.
Solution
You need to show your Toast by adding .show()
at the end:
Toast.makeText(this, dateSelected, Toast.LENGTH_LONG).show();
Hope this helps.
Answered By - Rostan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.