Button hoursButton = (Button) findViewById(R.id.hours);
final AlertDialog.Builder openinghours = new AlertDialog.Builder(this);
hoursButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openinghours.setTitle("Opening Hours");
openinghours.setMessage(
"\nMonday: CLOSED"
+ "\nTuesday: CLOSED"
+ "\nWednesday: 22:00 - 3:00"
+ "\nThursday: CLOSED"
+ "\nFriday: 22:00 - 3:00"
+ "\nSaturday: 22:00 - 3:00"
+ "\nSunday: CLOSED");
openinghours.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
显示营业时间。我希望实际的开放时间以一条整齐的直线显示,这就是它显示的方式:
我正在尝试将弦线分开,以使它看起来都是直线的,形成的线条。
必须有更好的方法吗?
答案 0 :(得分:2)
如果您有对话框的xml文档,则可以使用重力对齐文本。
进一步阅读:Alert dialog aligning
答案 1 :(得分:1)
您需要创建一个XML布局并创建一个表。
我知道这不是代码,但我没有打开我的想法
<table>
<row><row>Monday</row><row>CLOSED</row></row>
<row><row>Tuesday</row><row>CLOSED</row></row>
</table>
然后,您需要在创建警报时设置布局。