android-dialog

Android dialogs are causing android.view.WindowManager$BadTokenException: Unable to add window

倾然丶 夕夏残阳落幕 提交于 2019-12-01 11:40:27
问题 I have putted my activities in childview and now I cannot display dialogs from my activities and adapters. In my logCat i'm getting 04-11 12:39:59.823: E/AndroidRuntime(12831): FATAL EXCEPTION: main 04-11 12:39:59.823: E/AndroidRuntime(12831): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@41971f18 is not valid; is your activity running? 04-11 12:39:59.823: E/AndroidRuntime(12831): at android.view.ViewRootImpl

How to set a default value to SharedPreferences programmatically?

情到浓时终转凉″ 提交于 2019-12-01 10:41:32
I am using SharedPreferences to keep the information about user's weight, which I need in my application. The problem is, how to set a default value (eg. 75 kg) automatically after installation? I know how to do it via .xml, but how to do this programmatically? My code: public class SettingsDialogFragment extends DialogFragment{ public static final String PREFS_NAME = "settings"; public Dialog onCreateDialog(Bundle savedInstanceState) { builder.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Data.weight = weight;

Positon an Acitvity applied with a theme dialog at a particular x, y position

女生的网名这么多〃 提交于 2019-12-01 09:38:57
问题 I would like to place the dialog on a particular position on the screen(-10px from top and -5px from let). I did apply the theme and added the android:scrollX , android:scrollY , but it doesn't seem to work. Any solutuions? Below is my styling xml. <style name="Theme.MyDialog1" parent="android:style/Theme.Dialog"> <item name="android:windowNoTitle">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:layout_width">300dp</item> <item name=

Positon an Acitvity applied with a theme dialog at a particular x, y position

假装没事ソ 提交于 2019-12-01 09:38:04
I would like to place the dialog on a particular position on the screen(-10px from top and -5px from let). I did apply the theme and added the android:scrollX , android:scrollY , but it doesn't seem to work. Any solutuions? Below is my styling xml. <style name="Theme.MyDialog1" parent="android:style/Theme.Dialog"> <item name="android:windowNoTitle">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:layout_width">300dp</item> <item name="android:scrollX">-10dp</item> <item name="android:scrollY">-5dp</item> </style> EDIT: I have also tried

Android sending messages between fragment and service

喜夏-厌秋 提交于 2019-12-01 06:37:32
问题 I have a fragment with a button. When clicked it tells a service to start polling sensors and then insert the sensor data into a database on a background thread. When the button is pushed again, the service will stop. When the Stop button is pushed, there may still be tasks in the executor queue that is inserting into the DB, so during this time I want to display a progress dialog, and dismiss it once the entire queue is clear. The fragment with the button looks like this: public class

Custom Dialog Fragment

依然范特西╮ 提交于 2019-12-01 06:08:22
I am trying to create a simplistic dialog similar to a DatePickerDialog . The Dialog that I am creating should provide the user with an array of images from which they can select. I believe I have managed to create the array and add the correct images to it, the problem I am running into now is how to get the Dialog to show up? What should I be returning? I have looked into AlertDialogs and such, but I am not sure as to what to do to implement them. UPDATED: FIXED PROBLEM, CODE SHOWN BELOW IS FUNCTIONING PICTURE PICKER public class PicturePickerFragment extends DialogFragment { ArrayList

View not attached to window manager (whats the solution?)

混江龙づ霸主 提交于 2019-12-01 03:58:01
I got hundreads of error reports from my app and all of them is the same. It is really annoying because in my test devices (HTC Wildfire, Galaxy S I-II-III, Galaxy Mini, Galaxy Tab 10) this error NEVER occured, neither to me or my test buddy, looks like users do something different then us. Because of this i cant give you too much information about the situation, there is one thing i see, it is something with a dialog's dismiss, which i actually never calls by code. here is the error: java.lang.IllegalArgumentException: View not attached to window manager at android.view.WindowManagerImpl

How to re size the Height of the Items in Spinner with multiple choice?

送分小仙女□ 提交于 2019-11-30 22:26:48
I just showing the spinner with multiple choice based on this stackoverflow answer(see @Destil answer) . Here my problem is I can't re size the Height of the items in Spinner with multiple choice. How to re size the Height of each Items? As i know, you will have to use a custom adapter, and override the getDropDown and the getView methods. You will be able to customize each item customizing the layout. Well... words are good, example better, try something like that : public class CustomStringArrayAdapter extends ArrayAdapter<String> { private Activity myActivity; public

How to load web view in dialoge in android

一笑奈何 提交于 2019-11-30 16:35:47
I am trying to load web view in to dialog. I am usuing the following code. final TextView seeMonthlyBill = (TextView) parentLayout .findViewById(R.id.my_ac_my_service_timewarnercable_link); seeMonthlyBill.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Dialog dialog = new Dialog(getActivity()); WebView wb = new WebView(getActivity()); wb.getSettings().setJavaScriptEnabled(true); wb.loadUrl("http://www.google.com"); wb.setWebViewClient(new HelloWebViewClient()); dialog.setCancelable(true); dialog.setContentView(wb); dialog.setTitle("WebView"); dialog.show(); }

DialogFragment displayed from onContextItemSelected doesn't survive onPause/onResume

一曲冷凌霜 提交于 2019-11-30 13:43:12
I have a DialogDragment which I can show one of two ways: 1) By tapping on a ListView item from its OnItemClickListener 2) By activating a the ListView's context menu and selecting a menu item Doing #1 works fine under all lifecycle events, but if I invoke it via #2 and I pause the activity (by going Home) and the resuming it via the task switcher, the dialog is no longer displayed. The fragment is there, and I can rotate the device and show the dialog. I experimented, and if I put the showing of the DialogFragment into a Handler with a delay of at least 1/2 seconds, it works. The following