「設定」ボタンを使用してアプリケーションを作成すると、そのボタンを押すと新しいアクティビティが作成されます。新しいアクティビティで実際の設定ページを表示したい。ここで新しいアクティビティが表示されない
は、[設定]ボタンのXMLコードです:
<Button
android:text="Settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/buttonResSettings" />
ここで私は私のメインの活動のOnCreate
にある新しいアクティビティを呼び出すコードです:
Button resSetButton = FindViewById<Button>(Resource.Id.buttonResSettings);
resSetButton.Click += delegate {
var ResSetAct = new Intent(this, typeof(ResSettingsActivity));
ResSetAct.PutExtra("res", res);
StartActivity(ResSetAct);
};
ここに私のコードだが、新しい活動:
public class ResSettingsActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set the view to ResSettings(.axml)
SetContentView(Resource.Layout.ResSettings);
//Fetch the data of the variables
string res = Intent.GetStringExtra("res");
//Map the elements of the view to usable objects
EditText CurRes = FindViewById<EditText>(Resource.Id.editCurRes);
//Display the current values of the settings
CurRes.Text = res;
}
}
残りのapのビルドと使用pは問題ありませんが、その設定ボタンをクリックすると、何も起こりません(デフォルトのonClickボタンのデザイン変更を除く)。
ヘッドアップありがとう!しかし、問題は解決しません。 – Slath
問題を再現できません。ここで問題なく動作します。 – Cheesebaron
Parveen Prajapatiの提案の後、 'var ResSetAct'を' Intent ResSetAct'に変更して解決しました。 – Slath