I have an event click BotaoFlutuante_Click but not work to show message and to call my class (work fine to change set image). I don´t know what i´m doing wrong. Can help me?
private void BotaoFlutuante_Click(object sender, System.EventArgs e)
{
botaoFlutuante.SetImageDrawable(GetDrawable(Resource.Drawable.iconeverde));
EnviaSms enviarSms = new EnviaSms();
enviarSms.EnviarSms();
Toast.MakeText(Application.Context, "PAPAPAPAPA", ToastLength.Long);
}
Toast.MakeText(Application.Context, "PAPAPAPAPA", Toast.LENGTH_LONG).show();
You are missing the .show(); syntax and also change the ToastLength.Long into Toast.LENGTH_LONG
I once also spent hours working with that problem.
Related
here is the problem. I am using a custom component from someone else called a "Fancy showcase view". It focuses on buttons in my activity on highlights them with a text as a tutorial through the app. I am starting the first message, and when the user dissmises this by clicking anywhere in the activity, the next button is supposed to be highlighted. Unfortunately, the component, which otherwise is perfect, doesnt have a listener implemented like "OnDismis" of the first tutorial view so the next could start. Just putting both into code one after the other skips the second one. It also tried working with lifecycle methods, such as OnFocuseChanged() but even after the tutorial gets dismissed, this method isnt called a second time. What would you guys say is the best way to handle this? Here is what is NOT working:
try
{
new FancyShowCaseView.Builder(this) // if this crashes, we need clean rebuild
.Title(title1)
.TitleStyle(0, (int)GravityFlags.Center | (int)GravityFlags.Center)
.Build()
.Show();
}
catch (Exception e)
{
Toast.MakeText(this, "There was an error ... " + e, ToastLength.Short).Show();
}
try
{
new FancyShowCaseView.Builder(this) // if this crashes, we need clean rebuild
.Title("TEST")
//.TitleStyle(0, (int)GravityFlags.Center | (int)GravityFlags.Center)
.FocusOn(txtL)
.Build()
.Show();
}
catch (Exception e)
{
Toast.MakeText(this, "There was an error ... " + e, ToastLength.Short).Show();
}
The second one doesnt show up. There are no event handlers and I cannot make use of lifecycle methods. Click counting wouldnt work either, since the user might click on the activity while it is loading so hard coded values arent a good option either. Any ideas?
Thanks:)
Use the FancyShowCaseQueue to control the sequence.
You add individual FancyShowCaseViews to it and when you "Show()" the queue, each FancyShowCaseView happens in the order in-which you added them to the queue.
Example:
var fancyView1 = new FancyShowCaseView.Builder(this)
.Title("StackOverflow 1")
.FocusOn(button1)
.Build();
var fancyView2 = new FancyShowCaseView.Builder(this)
.Title("StackOverflow 2")
.FocusOn(button1)
.Build();
var fancyQueue = new FancyShowCaseQueue()
.Add(fancyView1)
.Add(fancyView2);
fancyQueue.Show();
I am using a Xamarin.Android binding library of FancyShowCaseView, but you can review the Java-based examples are in the sample app in the repo, ie:AnimatedActivity.java
Also you can implement the ME.Toptas.Fancyshowcase.IDismissListener interface:
public void OnDismiss(string p0)
{
//
}
public void OnSkipped(string p0)
{
//
}
And use that implementation on each of your FancyShowCaseViews:
var fancyView2 = new FancyShowCaseView.Builder(this)
.Title("StackOverflow 2")
.FocusOn(button2)
.DismissListener(this)
.Build();
I am trying to make a toast display some text given certain conditions inside an onClickListener. The app won´t run in the simulator, and I get the following error: "void cannot be converted to Toast"
I have searched around, and find several similar problems and solutions on this forum, but none of them applies completely to my problem. The others haven´t used the correct context in the statement, but I really mean that I do. (The name of the javafile (context) is: "Case1Activity") Can anyone help me with this?
I have simplified the code a bit:
public void onClick(View view) {
if (button1Pushed == false){
count++;
Toast toast = Toast.makeText(Case1Activity.this, "You are doing this in the right order!", Toast.LENGTH_LONG).show();
}
}
});
do it without assignment statement
Toast.makeText(Case1Activity.this, "You are doing this in the right order!", Toast.LENGTH_LONG).show();
apply it as.
Toast.makeText(Case1Activity.this, "You are doing this in the right order!", Toast.LENGTH_LONG).show();
if you want to use assignment operator then you can use below code
Toast toast = Toast.makeText(context, text, duration);
toast.show();
Dear Friend check below before eating Toast,
Your Toast (Incompatible types error) :
Toast toast = Toast.makeText(Case1Activity.this, "You are doing this in the right order!", Toast.LENGTH_LONG).show();
Normal Case (Standard Use):
Toast.makeText(Case1Activity.this, "You are doing this in the right order!", Toast.LENGTH_LONG).show();`
Special Case (if you need reference of Toast):
View toast = Toast.makeText(MainActivity.this, "You are doing this in the right order!", Toast.LENGTH_LONG).show();
because here ".show()" method is -
public void show () which
shows the view for the specified duration.
Thanks
Here is a function that gets called when an item gets selected from a ListView:
async void detail_clicked(object sender, SelectedItemChangedEventArgs e){
if (e.SelectedItem == null) {
return;
}
Detail selected = (Detail)e.SelectedItem;
order_vm.List_of_details.Add(selected);
await DisplayAlert ("Item Added",
String.Format ("{0} added to cart.", selected.detail_name), "Okay");
((ListView)sender).SelectedItem = null;
}
I added this function using the ItemSelected event handler
details_list.ItemSelected += detail_clicked;
The first time I click on the Item, the DisplayAlert pops up. After the first click, the DisplayAlert inside detail_clicked no longer pops up. But the other code inside the handler does get called.
Anyone know how to fix this issue? Is it something I am not understanding about event handlers? Is it something about await/async?
The DisplayAlert might be running on a different thread. Try wrapping Display Alert in Device.BeginInvokeOnMainThread. You can ready about that here.
Please check again without async on method and await on DisplayAlert().
Use this following code. It will helps you.
private void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
{
if (e.SelectedItem == null)
{
return;
}
listView.SelectedItem = null;
DisplayAlert("Alert", e.SelectedItem.ToString(), "Ok");
}
Am trying to get the ImageView drawable and use it to create an if else statement, i have tried many solutions including the one below, all are not working they always give me the wrong Toast
if(holder.likeImage.getDrawable()==context.getResources().getDrawable(R.drawable.ic_action_like)){
Toast.makeText(context, "LIKED ALREADY", Toast.LENGTH_SHORT).show();
}
else if(holder.likeImage.getDrawable()!=context.getResources().getDrawable(R.drawable.ic_action_like)){
Toast.makeText(context, "YOU HAVNT LIKED", Toast.LENGTH_SHORT).show();
}
try this.
holder.likeImage.setImageResource(R.drawable.ic_action_like);
holder.likeImage.setTag(R.drawable.ic_action_like);
if(holder.likeImage.getTag().equals(R.drawable.ic_action_like)){
}else{
}
I'm using cognalys sdk in my app for user verification but i get the errors 551 and 550 which are not listed on their site and I don't know what are they, here is the code I use:
Cognalys.verifyMobileNumber(SignupActivity.this,"token",
"id","number",
new VerificationListner() {
#Override
public void onVerificationStarted() {
Toast.makeText(getApplicationContext(), "Started", Toast.LENGTH_LONG).show();
}
#Override
public void onVerificationFailed(ArrayList<String> errorList) {
for (String error : errorList) {
Log.d("abx", "error:"+error);
}
Toast.makeText(getApplicationContext(), "Failed", Toast.LENGTH_LONG).show();
}
#Override
public void onVerificationSuccess() {
Toast.makeText(getApplicationContext(), "Signed up successfully !", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(SignupActivity.this, SetPictures.class);
startActivity(intent);
finish();
}
});
instead of number I put my number from my code, I get the missed call but the toast "failed" shows up with error 550 in my log, can anybody tell me what does it mean?
Error codes: https://www.cognalys.com/androidlibraryerrors/
Android lib source code: https://github.com/cognalys/cognalys-android-library
Don't use the jar from their website. Download the one on github and include it in your project. Then you have to make a change in their code.
In the class CallListnerHelper, when a call comes, the incoming number is compared to a list of numbers they send. On my Xperia Z3c, the incoming number starts with 00. They send the list of excepted number all starting with '+'. The comparison always fails, so you have to handle that. Use the following library: https://github.com/googlei18n/libphonenumber
We are now Sending number numbers list/array With + and 00 . Can you guys please re-check .We should know the problem is fixed or not . Thanks for the valuable update