android-dialog

Android make a dialog appear in fullscreen

為{幸葍}努か 提交于 2019-11-27 01:19:16
问题 I need the dialog to fill the screen except for some space at the top and the bottom. I've search for a solution but couldn't find one probably because I'm declaring it in an onClickListener . Can someone please give a solution? Activity code: sort.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub AlertDialog.Builder sort = new AlertDialog.Builder(HomeScreen.this); // Get the layout inflater LayoutInflater inflater =

findViewById() returns null for Views in a Dialog

随声附和 提交于 2019-11-26 22:58:50
The problem is, no matter where or how I call for this layout's components, they always return null. setView(inflater.inflate(R.layout.search_layout, null)) This works fine. It displays the layout inside the Dialog , yet, the children are always returned as null by findViewById(R.id.some_search_layout_children) . I've tried cleaning my project multiple times, tried to implement another class for my Dialog , called findViewById() as a member of my main Activity , inside the initSearch() method, and inside an anonymous implementation of OnClickListener for the Dialog , but all with the same

Change background of ProgressDialog

China☆狼群 提交于 2019-11-26 22:14:09
I am trying to change the background of a ProgressDialog . I searched the net and found various suggestions (like How to remove border from Dialog? ), but I am unable to replace the actual background of the ProgressDialog . Instead I get another background (yellow) behind the dialog: My style: <style name="StyledDialog" parent="@android:style/Theme.Dialog"> <item name="android:windowBackground">@drawable/panel_background</item> </style> The code that launches the ProgressDialog : ProgressDialog dialog = new ProgressDialog(this, R.style.StyledDialog); dialog.setTitle("The title"); dialog

Get date from datepicker using dialogfragment

怎甘沉沦 提交于 2019-11-26 21:31:30
I'm using the google example to insert a datepicker inside my app using a dialogfragment http://developer.android.com/guide/topics/ui/controls/pickers.html But I'm not sure how to get date after set it (not java expert). Dialog and datepicker runs ok and I can log that date is correctely set but, how can i do to get a callback executed on parent activity? This is my Dialog fragment public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date

AlertDialog: How To Remove Black Borders Above and Below View

别说谁变了你拦得住时间么 提交于 2019-11-26 19:59:39
问题 This question has been asked before: AlertDialog custom title has black border But was not answered satisfactorily - and is missing some information. I'm trying to create a custom dialog in Android without a title and without any buttons along the bottom. However, the resulting dialog has black "borders"/"spacing"/something along the top and bottom of the view. From the Documentation: A dialog made with the base Dialog class must have a title. If you don't call setTitle(), then the space used

How to set DialogFragment's width and height?

这一生的挚爱 提交于 2019-11-26 18:05:56
I specify the layout of my DialogFragment in an xml layout file (let's call it layout_mydialogfragment.xml ), and its layout_width and layout_height attributes particularly (to be 100dp each let's say). I then inflate this layout in my DialogFragment's onCreateView(...) method as follows: View view = inflater.inflate(R.layout.layout_mydialogfragment, container, false); Unfortunately, I find that when my dialog (DialogFragment) appears, it does not respect the layout_width and layout_height specified in its xml layout file (and my dialog shrinks or expands variably depending on content). Anyone

How do I fire an event when click occurs outside a dialog

烂漫一生 提交于 2019-11-26 16:13:18
问题 I would like to know how to solve a problem I've got. I have a Dialog which pops up in an activity. The Dialog doesn't cover the whole screen, so the buttons from the activity still show. I can easily close the dialog when there is a touch outside the dialog's bounds with dialog.setCanceledOnTouchOutside(true); However what I want to do is fire an event if a click is outside the Dialog's bounds (e.g if someone touches a button on the main Activity, it should close the Dialog and fire that

AlertDialog with positive button and validating custom EditText

醉酒当歌 提交于 2019-11-26 16:10:27
问题 I have created simple AlertDialog with positive and negative buttons. Positive button has registered DialogInterface.OnClickListener , where I get EditText value. I have to validate it (for example if it has to be not null) and if value is not correct, disallow to close this dialog. How to prevent dismissing dialog after click and validate ? 回答1: Dialog creation: AlertDialog.Builder builder = new AlertDialog.Builder(YourActivity.this); builder.setCancelable(false) .setMessage("Please Enter

How to display progress dialog before starting an activity in Android?

走远了吗. 提交于 2019-11-26 13:05:25
How do you display a progress dialog before starting an activity (i.e., while the activity is loading some data) in Android? Matthew Willis You should load data in an AsyncTask and update your interface when the data finishes loading. You could even start a new activity in your AsyncTask's onPostExecute() method. More specifically, you will need a new class that extends AsyncTask: public class MyTask extends AsyncTask<Void, Void, Void> { public MyTask(ProgressDialog progress) { this.progress = progress; } public void onPreExecute() { progress.show(); } public void doInBackground(Void... unused

How to show a dialog to confirm that the user wishes to exit an Android Activity?

余生长醉 提交于 2019-11-26 11:59:12
I've been trying to show a "Do you want to exit?" type of dialog when the user attempts to exit an Activity. However I can't find the appropriate API hooks. Activity.onUserLeaveHint() initially looked promising, but I can't find a way to stop the Activity from finishing. jax In Android 2.0+ this would look like: @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