0
我的活动被称为CwiLogInActivity。我宣布它在我的启动画面像这样:Android错误“无法找到显式活动类”c#
StartActivity(new Intent(Application.Context, typeof(CwiLogInActivity)));
错误消息:
Android.Content.ActivityNotFoundException: Unable to find explicit activity class {CwiMyCardApp.CwiMyCardApp/md5de4cbc02688eb358b61123b78d100d94.CwiLogInActivity}; have you declared this activity in your AndroidManifest.xml?
Android清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="CwiMyCardApp.CwiMyCardApp" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="19" />
<application android:label="CwiMyCardApp">
<activity android:name=".CwiLogInActivity"/>
</application>
</manifest>
我使用cheeseknife来解决我的资源和我没有编译问题。我在运行时遇到了错误。
CwiLogInActivity.cs
class CwiLogInActivity : AppCompatActivity
{
static readonly string TAG = "X:" + typeof(CwiLogInActivity).Name;
[InjectView(Resource.Id.loginName)]
EditText loginName;
[InjectView(Resource.Id.passWord)]
EditText passWord;
[InjectView(Resource.Id.loginButton)]
Button loginButton;
[InjectOnClick(Resource.Id.loginButton)]
void OnClickMyButton(object sender, EventArgs e)
{
// This code will run when the button is clicked ...
}
[InjectOnFocusChange(Resource.Id.loginName)]
void OnLoginFocusChange(View v, bool hasFocus)
{
if (hasFocus)
{
loginName.Text = "";
loginName.SetTextColor(Color.Argb(150, 000, 000, 000));
}
}
[InjectOnFocusChange(Resource.Id.loginName)]
void OnPasswordFocusChange(View v, bool hasFocus)
{
if (hasFocus)
{
passWord.Text = "";
loginName.SetTextColor(Color.Argb(150, 000, 000, 000));
}
}
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Log.Debug(TAG, "SplashActivity.OnCreate");
// Inflate the activity layout resource
SetContentView(Resource.Layout.LoginLayout);
// Use Cheeseknife to inject all attributed view
// fields and events. For an activity injection,
// simply pass in the reference to this activity.
Cheeseknife.Inject(this);
}
}
这似乎与大多数提供给其他人谁了我的问题的解决方案产品线。但我仍然存在。
嗯现在它编译,但只是进入一个空白屏幕......我添加了'[Activity(label =“MyCwiCardApp”)]'其中“MyCwiCardApp”是应用程序的名称 –
听起来像一个不同于这里描述的问题。也许你注入的视图项目工作不正常?尝试给出'SetContentView()'布局,你知道将显示只是为了仔细检查。 –
我在SetContentView()中设置了一个断点,它从不触发 –