有人能帮帮我吗?我想删除选项圈和每个项目的选择文本之间的空间(在图片中提到)。我的意思是我要把每个选择的文字都贴在圈子里。为此,我在onCreate()方法中调用了一个方法。 Tnx提前。这是我的代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (Build.VERSION.SDK_INT >= 17)
{
Locale fa = new Locale ( "fa" );
Locale.setDefault ( fa );
Configuration config = new Configuration ();
config.locale = fa;
getApplicationContext ().getResources ().updateConfiguration ( config, getApplicationContext ().getResources ().getDisplayMetrics () );
}
//fa is a Rtl language
getWindow ().setFlags ( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN );
alert();
}
public void alert() {
final AlertDialog.Builder ad = new AlertDialog.Builder(this);
ad.setTitle(" چته ؟ ");
ad.setCancelable(false);
ad.setSingleChoiceItems(mylist, -1, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "you choose : " + mylist[which], Toast.LENGTH_SHORT).show();
}
});
ad.setPositiveButton(" تایید ", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "you confirm", Toast.LENGTH_SHORT).show();
}
});
ad.setNegativeButton(" انصراف ", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "you canceled it", Toast.LENGTH_SHORT).show();
}
});
final AlertDialog alertDialog = ad.create();
alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
Button pos = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
Button neg = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
alertDialog.getWindow().setLayout(1000,800);
pos.setTextSize(18f);
neg.setTextSize(18f);
}
});
alertDialog.show();
}