我想创建一个自定义对话框,其中包含列表视图下方的列表视图和按钮.按钮应位于列表视图下方,但始终可见(layout_alignParentBottom ="true").
我已经创建了一个非常好用的xml,但仅限于长列表.如果列表很短,则按钮仍位于屏幕底部,并且对话框标题的高度将拉伸以生成对话框填充屏幕.附图显示了我今天得到的结果.
简而言之.我想要一个普通的对话框,如果nececcary只填充屏幕.
我出于某种原因无法发布xml.但是我使用了relativelayout,按钮对齐父母底部,小面板布置在按钮上方,listview布置在此面板上方.所有布局都是布局:height = wrap_content.
感谢任何帮助./马格努斯

我正在使用以下代码向用户显示基本的文本框输入.
一切都很好.但是,第二次调用对话框时,应用程序崩溃了.
我怀疑这是因为我没有破坏我添加到View中的EditText.那么......对于那些比我更有经验的人来说......处理这个问题的正确方法是什么?
下面是我的代码和LogCat
final EditText ipInput = new EditText(this);
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(ipInput);
builder.setTitle("Enter Server IP Address: ");
builder.setPositiveButton("Save", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//STORE IP ADDRESS
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//CANCELLED
}
});
builder.create();
Run Code Online (Sandbox Code Playgroud)
而"展示":
settings.setOnClickListener(new OnClickListener(){
public void onClick(View view){
builder.show();
}
});
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪:
02-24 02:08:55.759: E/AndroidRuntime(582): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on …Run Code Online (Sandbox Code Playgroud) 我一直在玩警报对话框.我想显示一个对话框,显示listview中列表项的特定信息.就像android的文件管理器的详细对话框一样.
图片:https://dl.dropbox.com/u/20856352/detailsbox.jpg
有关此详细信息对话框的有趣之处在于,它显示的列表项与首选项屏幕中的首选项非常相似.他们可以点击它们,它们显示了一个非常漂亮的两行项目列表项目.
我需要创建一个类似的对话框,但我不知道如何实现这一目标.我玩了一下.首选项XML不能用作alertdialog的布局.而且我无法开发出类似于上面图片的布局.需要帮助/指南如何实现这一目标.
法拉兹爱资哈尔
我想使用AlertDialog.Builder创建一个启动画面,一个自定义视图和一个计时器.
我正在使用Xamarin.Android - 我似乎没有'dismiss'方法,我可以称之为'dispose'但是alertDialog视图没有关闭.
示例代码如下:
public class SplashDialog
{
private readonly AlertDialog.Builder _alert;
private readonly View _view;
public SplashDialog(Context context)
{
_alert = new AlertDialog.Builder(context);
var layoutInflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);
_view = layoutInflater.Inflate(Resource.Layout.splash, null);
_alert.SetView(_view);
}
public void Show()
{
_alert.Show();
/*
new Thread(() =>
{
Thread.Sleep(3000);
_view.Dispose();
_alert.Dispose();
}).Start();
* */
new Handler().PostDelayed(() =>
{
_view.Dispose();
_alert.Dispose();
}, 3000);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个AlertDialog,其中包含一个“下一步”和“关闭”按钮以及一个“不再显示”复选框。我为DialogFragment使用支持库。以下代码运行正常,但我想为此AlertDialog使用自己的xml布局:
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
int title = getArguments().getInt("num");
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("ASDASDAS")
.setPositiveButton(R.string.hello_world,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
((MainActivity)getActivity()).doPositiveClick();
}
}
)
.setNegativeButton(R.string.cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
((MainActivity)getActivity()).doNegativeClick();
}
}
);
return builder.create();
}
Run Code Online (Sandbox Code Playgroud)
是否可以使用我自己的xml布局创建此AlertDialog?
以下是我的代码,
public class Assignment_Create extends Activity implements OnClickListener {
DataManipulator dataManipulator;
static final int DIALOG_ID = 1;
AlertDialog.Builder dialogAc;
ImageView imageViewDateAssign, imageViewDueDate, imageViewSubmit;
TextView textViewDtAssign, textViewDueDt;
EditText editTextTitle, editTextDesc;
static final int DATE_DIALOG_ID = 0;
int cDay, cMonth, cYear;
private TextView activeDateDisplay;
private Calendar activeDate;
// Update database
String updateId;
public boolean isEdit;
@Override
public void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.assignment_create);
imageViewDateAssign = (ImageView) findViewById(R.id.dateassign);
imageViewDueDate = (ImageView) findViewById(R.id.duedate);
imageViewSubmit = (ImageView) findViewById(R.id.submit);
textViewDtAssign = (TextView) findViewById(R.id.textViewDateAssign);
textViewDueDt = …Run Code Online (Sandbox Code Playgroud) 我创建了一个自定义AlertDialog使用圆角onDraw的LinearLayout下面,
public class RoundedLinearLayout extends LinearLayout {
private Paint drawPaint;
private Paint roundPaint;
private int mCornerRadius = 100;
private RectF bounds;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public RoundedLinearLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
onInit();
}
public RoundedLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
onInit();
}
public RoundedLinearLayout(Context context) {
super(context);
onInit();
}
protected void onInit() {
drawPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
drawPaint.setColor(0xffffffff);
drawPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
roundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
roundPaint.setColor(0xffffffff);
setWillNotDraw(false);
}
@Override
protected void onSizeChanged(int w, int …Run Code Online (Sandbox Code Playgroud) 我正在尝试调整我之前做过的AlertDialog,但是不记得我是怎么做到的.下面是我使用的代码,但它只是工作.是否有人能够指出我做错了什么.
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
alertDialogBuilder
.setMessage(R.string.checkout_journey_selector_popup_title)
.setPositiveButton(R.string.checkout_journey_selector_popup_paylater_button,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
CheckoutHelper.startReservationJourney(getActivity(),
collectibleItems);
}
})
.setNegativeButton(R.string.checkout_journey_selector_popup_paynow_button,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
CheckoutHelper.startPrepayCollectionJourney(getActivity(),
collectibleItems);
}
}).create().show();
Dialog alert = alertDialogBuilder.create();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(alert.getWindow().getAttributes());
lp.height = 100;
lp.width = 50;
alert.getWindow().setAttributes(lp);
Run Code Online (Sandbox Code Playgroud)
提前致谢
我想,如果禁用wifi,则向用户显示一个对话框,可以决定是否要启用或禁用wifi.
好吧,我可以看看是否启用了wifi,但我怎么能显示该设置对话框.
这是我正在使用的代码:
if(wifiMan.isWifiEnabled()==false){
Log.i("DEBUG","turning on wifi");
wifiMan.setWifiEnabled(true);//I would like that the user decide
}
else {
Log.i("DEBUG","wifi is on");
}
Run Code Online (Sandbox Code Playgroud)
PS:我使用过:startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); 但我收到此错误:ACTION_WIFI_SETTINGS无法解析或不是字段
我想有这个互动对话:

我有一个监视前台应用程序的后台服务。它用于保护某个应用程序,这样,如果受保护的应用程序在前台,然后由于另一个应用程序启动而被推送到后台,它将向用户显示另一个应用程序已接管前台应用程序的通知。
我能够检测到该开关,但是有什么方法可以显示Toast通知/ AlertDialog,以便在检测到该警报后在服务中提醒用户?
android toast android-service android-notifications android-alertdialog
android ×9
dialog ×2
android-wifi ×1
button ×1
destroy ×1
java ×1
listview ×1
memory-leaks ×1
toast ×1
transparency ×1
view ×1
xamarin ×1