我的活动名为CwiLogInActivity。我在Splash画面中声明它是这样的:
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);
}
}
这似乎与提出问题的其他人提供的大多数解决方案一致。然而我的仍然存在。
答案 0 :(得分:1)
此活动未定义[Activity]
属性。因此它永远不会被注入AndroidManifest.xml