我什至试图在 AlertDialog 中获取我的按钮。目前,一个按钮的文本进入第二行,使该按钮比其他两个稍大。这是我的对话框(不在片段中,只是在活动中)
public void imageActions(final View v, final int position) {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Image Actions");
alert.setIcon(R.drawable.image_icon);
alert.setNeutralButton("View Image", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
seeImage(v,position);
} });
alert.setPositiveButton("Remove Image", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
sureToDelte(v,position);
} });
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
} });
alert.show();
}
我尝试在之后添加此代码,alert.show();
但它导致了崩溃。
Button positive = (Button) findViewById(android.R.id.button1);
positive.setLayoutParams(new LinearLayout.LayoutParams(10, 10));
Button negative = (Button) findViewById(android.R.id.button2);
negative.setLayoutParams(new LinearLayout.LayoutParams(10, 10));
Button neutral = (Button) findViewById(android.R.id.button3);
neutral.setLayoutParams(new LinearLayout.LayoutParams(10, 10));