Я пытался изменить свой AlertDialog, чтобы он отображал текст в правильном направлении (для иврита).
С помощью Иназарука здесь: Правильный выравнивание текста в AlertDialog
Мне удалось получить диалоговое окно, но оно корректно работает только в эмуляторе (Eclipse).
Когда я перемещаю его на свое устройство (Xpersia X10a), в верхней части экрана появляется окно с фоном, блокирующим все, что за ним.
Изображение на эмуляторе:
![enter image description here](https://i.stack.imgur.com/ZlkVd.png)
Изображение на моем устройстве:
![enter image description here](https://i.stack.imgur.com/i4ldB.png)
Код:
public class test extends Activity {
/** Called when the activity is first created. */
public class RightJustifyAlertDialog extends AlertDialog {
public RightJustifyAlertDialog(Context ctx) {
super(ctx, R.style.RightJustifyTheme); } }
@Override
public void onCreate(Bundle savedInstanceState) {
final Context con = this;
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
AlertDialog dialog = new RightJustifyAlertDialog(con);
dialog.setButton("button", new OnClickListener(){
public void onClick(DialogInterface arg0, int arg1)
{
}
});
dialog.setTitle("Some Title");
dialog.setMessage("Some message");
dialog.show();
}
});
}
}
Стили:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="RightJustifyTextView" parent="@android:style/Widget.TextView">
<item name="android:gravity">right|center_vertical</item>
<item name="android:layout_centerVertical">true</item>
</style>
<style name="RightJustifyDialogWindowTitle" parent="@android:style/DialogWindowTitle" >
<item name="android:gravity">right|center_vertical</item>
<item name="android:layout_centerVertical">true</item>
</style>
<style name="RightJustifyTheme" parent="@android:style/Theme.Dialog.Alert">
<item name="android:textViewStyle">@style/RightJustifyTextView</item>
<item name="android:windowTitleStyle">@style/RightJustifyDialogWindowTitle</item>
</style>
</resources>
Мое устройство работает с Android 2.1-update1, и эмулятор настроен на то же самое.