- public class DateFormatSymbolSampleActivity extends Activity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- DateFormatSymbols symbols = new DateFormatSymbols();
- TableLayout table = (TableLayout) findViewById(R.id.symbols);
- addTableRow(inflater, table, "getAmPmString", Arrays.toString(symbols.getAmPmStrings()));
- addTableRow(inflater, table, "getEras", Arrays.toString(symbols.getEras()));
- addTableRow(inflater, table, "getMonths", Arrays.toString(symbols.getMonths()));
- addTableRow(inflater, table, "getShortMonths", Arrays.toString(symbols.getShortMonths()));
- addTableRow(inflater, table, "getWeekdays", Arrays.toString(symbols.getWeekdays()));
- }
- private void addTableRow(LayoutInflater inflater, TableLayout table, String text1, String text2) {
- TableRow row = (TableRow)inflater.inflate(R.layout.row, table, false);
- ((TextView)row.findViewById(R.id.text1)).setText(text1);
- ((TextView)row.findViewById(R.id.text2)).setText(text2);
- table.addView(row);
- }
- }
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <TableLayout
- android:id="@+id/symbols"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- />
- </LinearLayout>
- <?xml version="1.0" encoding="utf-8"?>
- <TableRow xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:padding="5dip"
- >
- <TextView
- android:id="@+id/text1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="5dip"
- />
- <TextView
- android:id="@+id/text2"
- android:layout_width="0dip"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:padding="5dip"
- />
- </TableRow>
英語ロケール
日本語ロケール
ドイツ語ロケール
フランス語ロケール
韓国語ロケール
ちなみに、1.6 だと、曜日名と月名がとれないバグがあるそうです。
Issue 3985 - android - DateFormatSymbols bugs in Japanese locale sdk1.6 - Project Hosting on Google Code
0 件のコメント:
コメントを投稿