我的意思是用“设置”按钮创建一个应用程序,这会在按下时创建一个新的活动。我想要这个新的活动来显示实际的设置页面。无法看到新的活动
这里的设置按钮的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