android,click,imageview,alertdialog
use this code in your button click as ImageView imgclose=(ImageView) inputdialogcustom.findViewById(R.id.btnclosepopup); imgclose.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { if(alert!= null && alert.isShowing()){ alert.dismiss(); } } }); And to get .dismiss() change final AlertDialog.Builder alert = new AlertDialog.Builder(context); to final AlertDialog.Builder alert = new AlertDialog.Builder(context).create(); ...
java,android,alertdialog,dialog-preference
What you're trying to do here is call a function that was added in API 21 instead of the one added in API 1. As per the documentation, you want setView(View view) instead of setView(int layoutResId). To get a View from a layout, you need a LayoutInflater. To get an...
Did you try to instantiate your builder inside the onclick event instead outside? ImageButton bracket = (ImageButton) findViewById(R.id.imageButton1); bracket.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { ArrayAdapter<String> adp = new ArrayAdapter<String>(arg0.getContext(), android.R.layout.simple_spinner_item, s); Spinner sp = new Spinner(arg0.getContext()); AlertDialog.Builder builder = new AlertDialog.Builder(arg0.getContext()); sp.setOnItemSelectedListener(new...
you didn't call show() on your AlertDialog: new AlertDialog.Builder(this) .setTitle("Facilities Review App") .setMessage("...") .setPositiveButton(..) .setNegativeButton(..) .show(); Here you can find the documentation for AlertDialog.Builder.show()...
android,validation,alertdialog,android-alertdialog
Finally, I have used the following approach to address my need (looping over multiple overridable verification), if it can help others : 1) My check function does not return boolean anymore. Instead in case of error, we just collect the error in a List<ValidationError>, ValidationError being a class containing the...
android,alertdialog,android-dialog
Actually you are triggering twice the code block to show the Alert Dialogue. So Alert Dialogue is showing one above another. It is not related with OK button click. There is no issues with the code snippet provided....
I guess you are looking for the window.confirm function. It let you choose between ok and cancel (in most browsers) and returns true or false. UPDATE You can use it like that if(!confirm("Do you want to continue?")) return; It will exit out of the function if you press cancel....
move the instantiation of the WebView just before accessing the object. s = rssItems.get(position).getDescription(); if(s.contains("href=")){ wv = new WebView(this); wv.loadData(s, "text/html", "UTF-8"); // other code ...
android,alertdialog,android-alertdialog
AlertDialog.Builder is used to build the alert dialog. After that, the create() method returns an AlertDialog object, which allows you to call dismiss(). AlertDialog.Builder builder = new AlertDialog.Builder(this); LayoutInflater inflater = getLayoutInflater(); View dialogView = inflater.inflate(R.layout.brush_opts_dialog,null); builder.setView(dialogView); closeBtn = (Button)dialogView.findViewById(R.id.close_btn); final AlertDialog dialog = builder.create(); closeBtn .setOnClickListener(new View.OnClickListener() { @Override...
java,android,xml,alertdialog,android-spinner
The view you are looking at is NOT a spinner, it's a NumberPicker. Take a look at the official Android Docs here; http://developer.android.com/reference/android/widget/NumberPicker.html
java,android,webview,alertdialog,findviewbyid
Try to use getView(). This will return the root view for the fragment, with this you can call findViewById(). class MyDialogFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Clear cache memory"); builder.setMessage("Do you want to delete cache memory ?"); builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {...
rgRating is not assigned to anything. So you will get a nullPointerException when calling getCheckedRadioButtonId. This would be obvious if you checked the stack trace or debugged the application. To fix it, assign an ID to rgRating in the XML file and do a rgRating = findViewById(...) ...before you try...
android,android-edittext,alertdialog
Once try as follows editText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { //...
javascript,variables,cordova,alertdialog,construct-2
You should use unobtrusive event listeners, as opposed to inline JS: <button id="headphone">headphone detected?</button> function detectHeadphones(){ window.plugins.headsetdetection.detect(function(detected){ if(!detected){ //No headphone detected alert("No headphone detected"); // Set your variables here } }) }; var headphoneButton = document.getElementById("headphoneButton"); headphoneButton.addEventListener('click', detectHeadphones); Then you can check detected for a falsey value thus: if(!detected){ and...
android,alertdialog,onbackpressed
Well this worked fine for me... @Override public void onBackPressed() { new AlertDialog.Builder (this) .setIcon (android.R.drawable.ic_dialog_alert) .setTitle ("Closing Activity") .setMessage ("Are you sure you want to close this activity?") .setPositiveButton ("Yes", new DialogInterface.OnClickListener () { @Override public void onClick (DialogInterface dialog, int which) { MainActivity.this.finish (); } }) .setNegativeButton ("No",...
android,android-fragments,alertdialog,android-ui
Extends DialogFragment and in onCreateDialog initialise it: If you want to use a simple dialog with two buttons, then you should follow this method by using AlertDialog.Builder. You can also set a custom layout by using setView. This will set a custom layout for the view BETWEEN the title...
Write it in activity that passing data Intent custaddress = new Intent(getApplicationContext(),com.example.frytest.Custaddress.class); custaddress.putExtra("key",value); startActivity(custaddress); Write below code in activity that catching data Intent intent=getIntent(); String mString=intent.getStringExtra("key"); hope this will help you...
android,rendering,alertdialog,numberpicker
Sorry, I misunderstood earlier. You just need to create a parent view and put your picker inside of that, using wrap_content. Here is how you do that in code: final NumberPicker picker = new NumberPicker(activity); picker.setMinValue(0); picker.setMaxValue(5); final FrameLayout parent = new FrameLayout(activity); parent.addView(picker, new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER)); builder.setView(parent);...
Your code seems correct, but try some things and let's see if it resolves: Check your imports for DialogFragment and AlertDialog, they should be the same on your Activity and the Convert_units_dialog. (If you're using appcompat-v7 library then other options for import will be shown) On setPositiveButton try calling dialog.dismiss();...
java,android,onclicklistener,alertdialog
You said that the button is inside dialog. But you try to find it in activity. I mean that until you try to show your dialog there it no the button at all and you try to find it from activity onCreate method. What you need to do is to...
AlertDialog.Builder builder = new AlertDialog.Builder(Activity.this); builder.setTitle("Sorry for Inconvinience"); buildersetMessage("You need to install MX Player or VLC Media Player"); .show(); The above code should work. I don't know what getApplicationContext(), R.style.TitleDialog); is used for though. ...
Ok, here's a workaround. First, I'll speculate that the problem is that the attempt to display the alert is happening before the looper for the UI thread has been started. Just a speculation. To work around the problem I added a recursive post which gets called from onResume(), like this:...
Apply setCancelable(false) to your AlertDialog.Builder instance....
Sure, this is possible, but I recommend you to display a timer not to let the user with a poker face when its dialog gets closed with no interaction. Here the steps to follow: To create a dialog use the DialogFragment with this tutorial to create one. To start a...
android,multithreading,automated-tests,alertdialog
I could solve the problem myself. It was really the @UiThreadTest annotation. Just run the critical parts in the method shift.runOnUiThread(). public void testDeleteButton() { final Shift shift = getActivity(); final Button deleteButton = (Button) shift.findViewById(R.id.shift_delete); final int deleteButtonViewMode = deleteButton.getVisibility(); assertEquals(View.VISIBLE, deleteButtonViewMode); shift.runOnUiThread(new Runnable() { @Override public void run()...
java,android,android-intent,alertdialog
You cannot "press the call button". You can use ACTION_CALL (instead of ACTION_DIAL), which will directly place the phone call. This requires the CALL_PHONE permission and will not work for emergency numbers (e.g., 911 in the US).
android,arrays,list,android-intent,alertdialog
It looks like you just need to take your code out of the for loop. Like so, final String[] choiceList = nome_op; final String[] idOperatoriList = id_nome_op; builder2.setItems(choiceList, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { Intent singole_usc = new Intent(getActivity(), Inserisci_m.class); Bundle extras = new Bundle();...
Use the below code in dialog class: Static AlertDialog alert; alert = builder.create(); alert.show(); Then use the following code in Fragment activity ViewCartDialog.alert.setTitle(" ");...
First of all do small changes on last 2 lines of your code.. wndInput.setView(txtEditScraps); final AlertDialog alertDialog = wndInput.create(); alertDialog.show(); Means you just have reference the alert dialog.. and then add the following code. alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Boolean wantToCloseDialog = (txtEditScraps.getText().toString().trim().isEmpty()); // if EditText...
Use an AlertDialog like below and the code below in your submit order button click DecimalFormat decimalFormat = new DecimalFormat(COMMA_SEPERATED); result.append("\nTotal: £"+decimalFormat.format(totalamount)); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this); alertDialogBuilder.setMessage(result.toString()); alertDialogBuilder.setPositiveButton("Accept", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { //do what you want to do if user clicks ok...
java,android,xml,alertdialog,android-alertdialog
You override the default onClick effect by putting a background color. android:background="@color/green" You can do it by creating a custom background xml file on drawable, like this. custom_background.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@color/Pressed_Color" /> <item android:state_activated="false" android:drawable="@color/green"/> </selector> then you call it on the button styling as...
There's no performance hit. There's no direct performance hit to putting methods in your adapter class. This is a java class, like any other, that just implements the necessary classes for it to function as an adapter. Whether you put your dialog creator / database lookups, in their own...
android,dialog,imageview,alertdialog
I ended up figuring out a way to solve this issue. Because manually changing the height of the ImageView removes the extra padding, I ended up finding the dimensions of the original image, and apply them to the ImageView once the ImageView dimensions can be calculated. Here is the final...
android,parameter-passing,alertdialog
You could pass the id into showPopup as a final int public void showPopup(final int id) { ... .setPositiveButton(getString(R.string.Alertdialognlja), new DialogInterface.OnClickListener() { public void onClick(DialogInterface Dialog, int which) { Log.i("positive", "clicked with id: " + id); } }) ... } ...
android,onclicklistener,alertdialog
You can change the behavior of the button immediately after calling show() of the dialog, like this. AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage("Test for preventing dialog close"); builder.setPositiveButton("Test", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Do nothing here because we override this button later to change...
android,validation,android-edittext,alertdialog
You're not telling the application that it should remain on AlertDialog, you're only setting a error to an object. A solution would be add onShowListener to the AlertDialog where you can then override the onClickListener of the button. Example: final AlertDialog d = new AlertDialog.Builder(context) .setView(v) .setTitle(R.string.my_title) .setPositiveButton(android.R.string.ok, null) //Set...
android,alertdialog,android-alertdialog
You have to create a custom theme. Here is the official guide: http://developer.android.com/guide/topics/ui/themes.html :) Something like this (in the style.xml file): <style name="CustomFontTheme" parent="android:Theme.Light"> <item name="android:textViewStyle">@style/MyTextViewStyle</item> <item name="android:buttonStyle">@style/MyButtonStyle</item> </style> <style name="MyTextViewStyle" parent="android:Widget.TextView"> <item...
java,android,alertdialog,indexoutofboundsexception
I think the problem is that you set default item state (checked or not) here: builder.setMultiChoiceItems(listMember, new boolean[] { false, false, false }, new DialogInterface.OnMultiChoiceClickListener() { for 3 items, but you can have a different number of item: mMemberList.size(), from the javadoc: checkedItems specifies which items are checked. It should...
android,alertdialog,android-alertdialog
Bits 24-31 of an Android Resource ID is the Package ID. Package IDs start at 1, 0 means this is not a base package. So 0x01000000 is the "start of real resource IDs". see the comments above "uint32_t id;" of "struct ResTable_package" in the android frameworks source file. "struct ResTable_package"...
java,android,android-edittext,alertdialog
Try this Create res/layout/custom_view.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Text 1" android:id="@+id/editText" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Text 2"...
As I said in my comment you should use custom dialog box. so create a new xml file for layout of your custom dialog box. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <Button android:id="@+id/button1" android:text="firstButton" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:id="@+id/dialogButtonOK"...
java,android,alertdialog,conform
Try to use this: AlertDialog.Builder alertbox = new AlertDialog.Builder(LauncherActivity.this); alertbox.setTitle("Are you sure?"); alertbox.setPositiveButton("YES", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(LauncherActivity.this, "You Choose Yes!!", Toast.LENGTH_LONG).show(); } }); alertbox.setNegativeButton("NO", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(LauncherActivity.this,...
java,android,gps,alertdialog,application-settings
You can use this to check if WiFi is enabled: public boolean isWiFiEnabled(Context context) { WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); return wifi.isWifiEnabled(); } To check if GPS is enabled you can use: public boolean isGPSEnabled (Context context){ LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); } EDIT: I'd use it this...
android,url,hyperlink,alertdialog
I am not sure whether it will work or not but you can try this text.setText(Html.fromHtml("<bMy Text is going here....</b>" + "<a href=\"http://www.example.com\">Terms and Conditions.</a> ")); text.setMovementMethod(LinkMovementMethod.getInstance()); ...
java,android,nullpointerexception,alertdialog
This much shorter program demonstrates the same problem, without as many irrelevant details: public class Main { public static void main(String[] args) { Boolean[] array = new Boolean[10]; if(array[0]) // <--- NullPointerException HERE System.out.println("true"); else System.out.println("false"); } } Because array[0] is a Boolean reference (not the primitive type boolean), if(array[0])...
android,dialog,alertdialog,android-alertdialog
add the following to your styles xml file: <style name="FullHeightDialog" parent="android:style/Theme.Dialog"> <item name="android:windowNoTitle">true</item> </style> use this to create the dialog (modify as you wish and set your ids for buttons) private void showDialog() { final Dialog dialog = new Dialog(this, R.style.FullHeightDialog); dialog.setContentView(R.layout.alert_dialog); //replace with your layout xml dialog.setCancelable(false); Button ignoreButton...
java,android,android-activity,dialog,alertdialog
Every View has a context, change: AlertDialog.Builder alert = new AlertDialog.Builder(context); to AlertDialog.Builder alert = new AlertDialog.Builder(v.getContext()); See the documentation for more info: http://developer.android.com/reference/android/view/View.html#getContext()...
android,button,alertdialog,android-5.0-lollipop,material-design
To summarize this topic for anyone interested: Android Material theme seems to have a bug with automatic button-width-span in alert dialogs. When you have for example 3 buttons, one of which having more than one word, the positive button will likely be squeezed out of the dialog to the right,...
android,alertdialog,android-alertdialog
Create a listener class first class CustomListener implements View.OnClickListener { private final Dialog dialog; public CustomListener(Dialog dialog) { this.dialog = dialog; } @Override public void onClick(View v) { // Do whatever you want here // If tou want to close the dialog, uncomment the line below //dialog.dismiss(); } } And...
java,android,dialog,alertdialog,android-alertdialog
Solved: the only problem is that it's not as nice looking AlertDialog.Builder builder = new AlertDialog.Builder(Home.theContext); builder.setMessage(R.string.confirm_delete); builder.setCancelable(true); builder.setPositiveButton(R.string.confirm_yes, vCabDelete()); builder.setNegativeButton(Home.theContext.getString(R.string.confirm_no), null); AlertDialog dialog = builder.create(); dialog.show(); .... private static DialogInterface.OnClickListener vCabDelete() { return new DialogInterface.OnClickListener() { public void...
android,input,textview,alertdialog,restriction
You can use Regex to make compare with the text input: String reg = "^[a-zA-Z0-9]*$"; final AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Change player"); alert.setMessage("Enter player name (cannot be empty)"); final EditText input = new EditText(this); input.setText("test"); alert.setView(input); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String tmPlayerName...
It should be something like the following code. The key point is to provide a boolean[] array of checkedItems and update it later when you try to select all. checkedItems array should be updated (because the Dialog still has reference to it.) And dialog.getListView().setItemChecked(i, true); should be called for every...
android,fragment,android-tabhost,alertdialog
My view wasn't directly inflated on the activity so I used the wrong FragmentManager, what I had to use was the getChildFragmentManager().
android,alertdialog,appcompat,android-theme,android-actionbar-compat
I couldn't reproduce the same exact error. However, I think that the problem is the context passed to AlertDialog.Builder constructor. In fact, an activity Context should be passed to it. Try replacing this line alertDialog = new AlertDialog.Builder(getApplicationContext()).create(); with this one alertDialog = new AlertDialog.Builder(this).create(); Please let me know if...
There is so much wrong with this it is hard to know where to begin :-( First of all, you cannot "sort" anything using a HashMap. These 2 concepts are mutually exclusive. Secondly, you have a while loop where you are creating and showing an AlertDialog for each row in...
You just need to create custom dialog, to have control over its title, content and all things around you dialog. Follow this link , or follow this link , or just make research in google with text "android dialog custom title" or with "android create custom dialog"...
android,bitmap,alertdialog,bitmapdrawable
Try setting a drawable from the resource just to see if that works. If I'm not wrong try changing the default app theme (It's weird but for me it worked in some special cases). Also I've found this bug report while searching, https://code.google.com/p/android/issues/detail?id=92929...
java,android,alertdialog,layout-inflater
You can make a Custom Dialog with your custom Layout. Here is a good tutorial: http://www.mkyong.com/android/android-custom-dialog-example/ Edit: Then you have to create your own row layout and custom ListView. Check these solutions: How to display list view in Alert Dialog in android? You can create custom adapters like this: public...
android,alertdialog,android-alertdialog
As you just need to display the same activity, just dismiss the dialog box while you click the negative button. alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { alertDialog.dismiss(); } } ...
android,listview,alertdialog,rss-reader
You need to change here alert.show(); to AlertDialog dialog = alert.create(); // You missed this dialog.show(): Edit: Remove this from loop and move to onCreate() after your asynctask executed. listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position,long id) { alert.setTitle(listview.getItemAtPosition(position).toString()); alert.setMessage(rssItems.get(position).getDescription()); //HERE YOU SHOULD SET THE...
Well, I use: AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); alertDialogBuilder.setTitle("Authentication Error!"); alertDialogBuilder .setMessage("User Name/Password is invalid.") .setCancelable(false) .setNeutralButton("Try Again",new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,int id) { dialog.cancel(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); See, if that shorten up your code....
android,android-activity,hyperlink,alertdialog
Use AlertDialog.setView() to display a custom layout containing your hyperlink TextView in the message area. E.g. Make a hyperlink_layout.xml containing a TextView with id = hyperlink_text It only has to contain what is shown in the message area of the AlertDialog, you don't need buttons/title etc. Create the AlertDialog something...
android,android-service,alertdialog
In DialogActivity implement BroadcastReceiver according to this link: How to close the activity from the service? So in your case before looping you should call sendBroadcast(new Intent("xyz")); which should close all activities created in previous loop....
android,lambda,alertdialog,android-alertdialog,autosuggest
It means that you can shorten up your code: example of onClickListener() without lambda : mButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // do something here } }); can be rewritten with lambda: mButton.setOnClickListener((View v) -> { // do something here }); It's the same code. This is...
When you built your dialog you have to create them by method create() from Builder class and after that you have to display it by method show() from Dialog class. You have to change way how you display dialog after click on: basicsBtn2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v)...
You'll want to use the set message method in your AlertDialog builder. .setTitle("Congratulations!") .setMessage("Your time was: " + updatedTime) .setIcon(R.drawable.ic_launcher) ...
The dialog popup is not the dialog shown. You create it, and then create another COMPLETELY DIFFERENT dialog when calling show(). Try calling the commands on popup directly: AlertDialog.Builder builder = new AlertDialog.Builder(this); final Dialog popup = builder.create(); final EditText edit = new EditText(this); edit.setGravity(Gravity.CENTER); edit.addTextChangedListener(new TextWatcher() { @Override public...
java,android,gridview,layout,alertdialog
If you post your logcat it'll be easier to help you. But I am guessing you are getting a NullPointerException on the line grid.setAdapter(adapter); When you call GridView grid = (GridView) findViewById(R.id.category_grid); You are going to get null (Unless their is a category_grid in your current layout) I think instead...
Once try as follows take AlertDialog as member variable class MyActivity extends Activity{ AlertDialog alertDialog=null; onCreate(-){ } } and create dialog as follows // create alert dialog alertDialog = alertDialogBuilder.create(); and then call dismiss() wherever you want in activity as alertDialog.dismiss(); Hope this will helps you....
android,mobile,onclick,alertdialog
If you don't have any specific reason to use Alert Dialog then you can use Progress Dialog. @Override public void onClick(View v) { xButton.setVisibility(View.INVISIBLE); new AsyncTask<Void, Void, Void>(){ ProgressDialog mProgressDialog; @Override protected void onPreExecute() { super.onPreExecute(); mProgressDialog = new ProgressDialog(<YourActivityClassName>.this); mProgressDialog.setMessage("message"); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); mProgressDialog.setCancelable(false);...
android,android-layout,android-5.0-lollipop,alertdialog
As said, new design guidelines clearly state that dialogs should have clear and concise texts, to let the user take a fast decision. Having long long actions is thus discouraged. However, from Lollipop onward, a new design pattern has been allowed to accomodate larger texts. Take a look here and...
you need to add swipeAlert.show();...
You cant change the margin color, but what you can do is wrap the contents in a new linear layout and change the background color of that! here is an example: btw the shadows on the buttons wont appear when you run the app. and the code: <?xml version="1.0" encoding="utf-8"?>...
I guess you have multiple buttons which open your dialog. In that case you should be able to know which button was pressed at that point where you add your onclick listener to the button which opens dialog. With this knowledge you can set a final field in the same...
Create somthing like this... First create your layout xml file... for eg: dialog.xml... and then call it like the below code wherever you want... final Dialog myDialog = new Dialog(this); myDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); myDialog.setContentView(R.layout.dialog); myDialog.setCancelable(false); Button yes = (Button) myDialog.findViewById(R.id.share); Button no = (Button) myDialog.findViewById(R.id.no); no.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View...
Try this Instead of using alert.dismiss(); Replace it by dialog.dismiss(); Like this @Override public void onClick(DialogInterface dialog, int which) { //save chosen sex String[] sex = new String[]{"male","female"}; mEditor.putString("sex", sex[which]); //don't open Dialog by next launch mEditor.putBoolean("used", true); mEditor.commit(); dialog.dismiss(); //auto launch next Dialog launchDialogBody(); } ...
java,android,database,variables,alertdialog
This is extremely hard to debug without the stack trace and the BdLocal code. However you can't add a dialog before the setContentView. Consider moving all of that code to the onResume method: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_camera); } @Override protected void onResume(){ super.onResume();...
I know you said you can't use android:configChanges="keyboardHidden|orientation|screenSize" because you have different layouts for landscape and portrait, but take a look aAndroid documentation concerning Handling the Configuration Change Yourself: @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Checks the orientation of the screen if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { Toast.makeText(this, "landscape",...
android,alertdialog,multi-select
I've looked into that problem too, and found no way to accomplish this without using custom adapter. Below the code which works. Here i create the ListView manually, and set a custom adapter for it. And then on every item click check for selected items. If there's no item selected,...
android,android-fragments,alertdialog
Please try calling listAdapter.notifyDataSetChanged() after you set the new list.
So I ended up solving this with a more custom XML layout that contains the message TextView instead of using .setMessage(). The XML ended up being: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="wrap_content" android:orientation="vertical"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center_vertical"...
android,dialog,android-animation,alertdialog
Found the solution on my own after a lot of digging through stack overflow answers with no results. The idea is to expand the entire dialog first to full screen, but have a transparent overlay view covering empty parts. The dialog.xml now looks like this: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">...
android,alertdialog,android-theme
Here is a working solution, based on Rod_Algonquin's idea of using a custom layout. private void showCustomAlert (String message) { // build dialog LayoutInflater inflater = getLayoutInflater(); View alertView = inflater.inflate (R.layout.custom_dialog, null); AlertDialog.Builder builder = new AlertDialog.Builder (this, R.style.CustomAlertDialog); builder.setView (alertView); final AlertDialog alert = builder.create(); // message ((TextView)alertView.findViewById...
java,android,nullpointerexception,alertdialog
Your costomdialog.xml does not have a TextView with id singlerow. Hence tv is null and when you call setText leads to NullPointerException. From your comments it looks like singlerow is a layout with textview with So Change this ArrayAdapter<String> adapter = new ArrayAdapter<String>(ChatActivity.this, R.layout.costumdialog, names) to ArrayAdapter<String> adapter = new...
android,alertdialog,android-softkeyboard
try to add this code: dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); should be the way. To me worked EDIT: this is another way i found: Dialog = builder.create(); Dialog.show(); Dialog.getWindow().clearFlags( WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); Dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); ...
android,android-edittext,alertdialog
If you have reference to the EditText that you want to write to, simply add the code to write to it in you onClick() method. The way to write text to an EditText is as follows yourEditText.setText("Your text");. So in your case, just set the text to your selected item.....
doInBackground() runs on a separate thread, other than the main thread. You can use UI elements only on main thread. Try using runOnUiThread() method inside doInBackground() to show the dialog.
android,dialog,imageview,alertdialog
Change getApplicationContext() to v.getContext()
android,timer,counter,alertdialog,onclicklistener
What problem are you having? Your AlertDialog is fine where it is but you probably want to set an onClickListener for your AlertDialog buttons. Here is an example of setting the onClickListener for the positive button: // Build an alert dialog AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this) .setTitle(getString(R.string.dialog_title)) .setMessage(getString(R.string.dialog_message)) .setCancelable(false) .setPositiveButton(getString(R.string.dialog_close_button),...
android,android-asynctask,alertdialog,getjson
!The doInBackground method is executed off the UI thread so any UI changes won't reflect in the UI. To make your dialog show, you will need to do that on the UI thread in onProgressUpdate or onPostExecute: /** * Async task class to get json by making HTTP call **/...
android,alertdialog,android-alertdialog
Try once by making AlertDialog alertDialog2 as class variable instead of defining and intializing in any function. AlertDialog alertDialog2; void tempFunction() { alertDialog2=new AlertDialog.Builder(MainActivity.this).create(); . . . . } Hope it helps... To understand this kind of thing give 2 mins to understand the memory map and stacking whenever a...
java,android,listview,alertdialog,onitemclicklistener
try this private void AlertDialogView() { final CharSequence[] items = { "One", "Two", "Three", "Four" }; AlertDialog.Builder builder = new AlertDialog.Builder(ShowDialog.this);//ERROR ShowDialog cannot be resolved to a type builder.setTitle("Alert Dialog with ListView and Radio button"); builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();...
android,android-layout,border,alertdialog,material-design
I found a solution for the grey line! :) I found the solution how to show the grey line at all here: How to make a static button under a ScrollView? For the check if I want to show it, I found the solution here: How can you tell when...
android,background,alertdialog
You can use v.setBackgroundColor(Color.WHITE); or v.setBackgroundColor(Color.parse("#ffffff")); this will change the background color to white...
inheritance,xamarin,alertdialog
You explicitly need to invoke one of the existing constructors from the super class. The error tells you, that there is no zero-argument constructor in Android.App.AlertDialog. This page lists available constructors. The general way to invoke a super-constructor then goes like this: class AlertDialogExtender : AlertDialog { public AlertDialogExtender() :...
Yes unfortunately you are missing something. I am assuming that you are calling your code on the main thread, first dialog.show() and then doing query.find() after that. Your problem is that you are (probably) doing all this work on the main thread, and the dialog will not show until the...