アクティビティ内に小さなポップアップオプションメニューを作成します。私はすでにメニューを示し、このコード状態変更時にスイッチボタン(AlertDialogにあります)を何かします
public void ShowOptionsDialog()
{
Android.Support.V7.App.AlertDialog.Builder optionDialog = new Android.Support.V7.App.AlertDialog.Builder(this);
optionDialog.SetTitle("Optionen");
optionDialog.SetView(Resource.Layout.Options);
optionDialog.Show();
}
Resource.Layout.Optionsは、次のものが含まれています:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<android.support.v7.widget.SwitchCompat
android:id="@+id/previewSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:hint="Preview der Dokumente anzeigen"/>
</LinearLayout>
どのように正確に私はスイッチが押されたときに何かをするアプリを教えてください(オンオフ)?
あなたは高速です。 ;-) –
既に提案したものに似たものを試しましたが、コードを使用するときに同じエラーが発生します: "System.NullReferenceException:オブジェクト参照がオブジェクトのインスタンスに設定されていません" しかし、 .. – fbueckle
このエラーが発生しました: Java.Lang.NullPointerException:ヌルオブジェクトリファレンスでインターフェイスメソッド 'int java.lang.CharSequence.length()'を呼び出そうとしました :/ – fbueckle