Why is my showcaseview showing behind my bottomsheetdialog in android? - java

I am trying to show a showcase inside my bottomsheetdialog, as shown in my code below:
MainActivity.java:
report.setOnClickListener(v -> {
final Dialog dialog = new Dialog(MainActivity.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.bottom_dialog_layout);
EditText report_bill_type = dialog.findViewById(R.id.bll);
dialog.show();
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable((Color.TRANSPARENT)));
dialog.getWindow().setGravity(Gravity.BOTTOM);
new GuideView.Builder(v.getContext())
.setTitle("Title here")
.setContentText("Description here")
.setGravity(smartdevelop.ir.eram.showcaseviewlib.config.Gravity.auto)
.setTargetView(report_bill_type) //showcase keeps showing behind the dialog
.setDismissType(DismissType.anywhere)
.build()
.show();
});
When I execute the code, the showcase keeps showing behind the dialog. How do I resolve this issue?
I am using this showcase view.

Related

How to run AlertDialog or DialogFragment quickly?

I have a Fragment that does the following:
showProgressBar();
controller.calc();
setTextResult();
hiddenProgressBar();
My showProgressBar:
ProgressBar loadingCalc = new ProgressBar(requireContext(), null, android.R.attr.progressBarStyle);
loadingCalc.setId(View.generateViewId());
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.gravity = Gravity.CENTER;
loadingCalc.setLayoutParams(layoutParams);
alertDialog = new AlertDialog.Builder(requireContext(), R.style.Dialog)
.setView(loadingCalc)
.setCancelable(false)
.create();
alertDialog.show();
My hiddenProgressBar:
if (alertDialog != null) {
alertDialog.dismiss();
}
First the Fragment executes the showProgressBar, leaving the AlertDialog visible. Then it calculates and in the end executes the hiddenProgressBar. Visually it doesn't. When I run the application it first performs the calculation and at the end it shows the AlertDialogand quickly withdraws it.
What the code is doing:
Calculate > showing the AlertDialog> hiding the AlertDialog
What should happen:
Show AlertDialog > Calculate > Hide AlertDialog
Observation: I've already tried using DialogFragment but it has the same behavior as AlertDialog. I just want a Dialog with a ProgressBar while Android does a calculation that can take a while.
How can I solve this?

'Running something in background inside a dialog

I have some codes like this:
ArrayList<Teacher> teachers = subs.get(position).getTeachers();
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
View v = LayoutInflater.from(MainActivity.this).inflate(R.layout.dialog_layout, null);
builder.setView(v);
ListView listViewDialog = (ListView) v.findViewById(R.id.dialog_lv);
TesAdapter adapter1 = new TesAdapter(MainActivity.this, teachers);
listViewDialog.setAdapter(adapter1);
adapter1.notifyDataSetChanged();
listViewDialog.setDivider(null);
builder.show();
This operation takes a lot of time. So, I am trying to show a ProgressDialog while it is loading. then to hide the progressbar and show this AlertDialog.
I have tried these:
How to show progress dialog in Android?
How can I run code on a background thread on Android?
But none of them worked :( any solution?

Star Rating in Dialogbox won't change saved value

// Custom Dialog Box
final AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this, R.style.Theme_AppCompat_Dialog_Alert);
final View mView = getLayoutInflater().inflate(R.layout.completed, null);
ImageButton imgForm = (ImageButton) mView.findViewById(R.id.RateButton);
mBuilder.setCancelable(false);
mBuilder.setView(mView);
final AlertDialog dialog = mBuilder.create();
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show(); // Dialogbox appears
// Interest Rating
final AlertDialog.Builder nBuilder = new AlertDialog.Builder( MainActivity.this, R.style.Theme_AppCompat_Light_Dialog_Alert);
final View nView = getLayoutInflater().inflate(R.layout.intrst, null);
Save_Intrst = (Button) nView.findViewById(R.id.SaveIntrst);
nBuilder.setCancelable(false);
nBuilder.setView(nView);
final AlertDialog dilog = nBuilder.create();
// LongPress Image Button
imgForm.setOnLongClickListener(new View.OnLongClickListener(){
#Override
public boolean onLongClick(View view){
dialog.dismiss();
dilog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dilog.show(); // Dialogbox appears
return true;
}
});
Save_Intrst.setOnClickListener(new View.OnClickListener(){
String IntrstLvl;
#Override
public void onClick(View v){
RatingBar rBar = (RatingBar)nView.findViewById(R.id.ratingStar);
IntrstLvl = Integer.toString(rBar.getNumStars());
addData(IntrstLvl);
dilog.dismiss();
Log.d(TAG,"Dismissed");
}
});
Whenever I select "save" within the Save_Intrst it saves 5 stars regardless of what I choose. I'm still fairly new to Android development and have been java coding for a bit now.
This is just a snippet of code of the project and I believe it will be enough, it shows my submit button, the submit button will launch a dialog box that will have a secret button in an image (ImgForm) the image doesn't show but that's not the problem, after long pressing it will launch another dialog that has a 5 Star Rating Bar and a Save button, this is used for rating after the person completes the previous requirements. The rating will always save "5" regardless of what was inserted, even after a reinstall of app onto the device.
getNumStars() will tell you the maximum number of stars shown and will always be 5 as you have defined it. If you want the actual selected rating, you will need getRating(). See this documentation.
You need to use the rBar.getRating()
RatingBar rBar = (RatingBar)nView.findViewById(R.id.ratingStar);
IntrstLvl = Integer.toString(rBar.getRating());
https://developer.android.com/reference/android/widget/RatingBar.html
You are calling getNumStars() which according to the documentation "Returns the number of stars shown." which means the total number of stars a user can select. You should instead be checking getRating() which returns the number of stars currently selected.
https://developer.android.com/reference/android/widget/RatingBar.html#getRating()

Android : screen width Dialog with adMob

I want to create dialog with adMob , but it always gives an error , that its not enough place to put it . so is it possible to make dialog width equal to screen width ?
here is how i create it all :
public void CreateDialog(){
Dialog d = new Dialog(this);
d.setTitle("Loading...");
LinearLayout ll = new LinearLayout(d.getContext());
ll.setLayoutParams( new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
ll.addView(adView);
d.setContentView(ll);
d.show();
}
// AdView is loading normally , and working without dialog;

BlackBerry Dialog box

I have some Android code, where I'm using Dialog class to display
public void createCustomDialog(String msg)
{
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("Error");
dialog.setCancelable(true);
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setText(msg);
ImageView img = (ImageView) dialog.findViewById(R.id.image);
img.setImageResource(android.R.drawable.ic_dialog_alert);
dialog.show();
}
Can anyone help me with the corresponding Blackberry code for it
You can use the BlackBerry Dialog class to do this.
You would use this:
Dialog.alert(String message);
as follows:
Dialog.alert.("This is a Dialog!");
Output (In a Dialog Box):
This is a Dialog!
To add Image Please see :
http://www.javaquery.com/2011/07/how-to-put-image-in-dialog-box.html

Categories

Resources