私はArrayAdapter
というかなり単純なダイアログを持っています。私は、このダイアログを表示するとAlertDialog内のAndroidスイッチウィジェット、サム画像を表示しない(代わりにオン/オフ)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp">
<TextView
android:id="@+id/txt_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/calendar_selection_switch"
android:ellipsize="end"
android:text="test test"
android:textColor="@color/black"
android:textSize="20sp" />
<Switch
android:id="@id/calendar_selection_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_gravity="end|center_vertical"
android:layout_marginStart="10dp"
android:minHeight="40dp"
android:minWidth="80dp" />
</RelativeLayout>
が、これは私が得るものです::アダプターは、次のようなレイアウトを膨張
お知らせ小さな文字でと「オン「と」オフ」の言葉。ここにカスタムグラフィックスやクラスはありません。すぐに使用できます。
Activity
でこれを行うと、私はそれを知りません。代わりに、私は私がしたい正確に何である通常の親指の画像を取得:
私はスイッチのサイズを育てる場合でも、それはどんな違いがありません。リストの行を大きくするだけです。
ここでダイアログを構築し、表示するコードです。
AlertDialog.Builder builderSingle = new AlertDialog.Builder(this);
builderSingle.setTitle(R.string.cal_title);
builderSingle.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
final CalendarListAdapter cla = new CalendarListAdapter(this, calendarList, null);
builderSingle.setAdapter(cla, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
cla.toggleSelect(which);
}
});
builderSingle.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (saveCalendars(cla)) {
dialog.dismiss();
}
}
});
AlertDialog dialog = builderSingle.create();
dialog.show();
CalendarListAdapter
シンプルArrayAdapter
です:
public class CalendarListAdapter extends ArrayAdapter<Calendar> {
このクラスのActivity
バージョンとAlertDialog
バージョン間に違いががありません。
私は困惑しています。私がここでやっていることはあまり複雑ではありません。助けてください。
これは私が尋ねてきた質問に対する答えだとは思わない。これは、AlertDialogの中にあるときと、アクティビティの中にあるときに、スイッチが異なって見えるのはなぜですか? – Emmanuel
それ以外の方法がない場合は、これを回避策として使用することがあります。 – Emmanuel
@Emmanuelは 'AlertDialog'の' support library'バージョンを使用していますか?私はそれが「図書館」の「引出し」を壊すことによると思う。 –