在較低版本Android Mobile中運行代碼時出現此錯誤。請幫助我如何解決這個問題。我尋找這個問題,但我沒有找到確切的地方,我犯了錯誤。Android.Content.Res.Resources + NotFoundException:資源ID#0x7f03005e
[ERROR] FATAL UNHANDLED EXCEPTION:Android.Content.Res.Resources+NotFoundException: Resource ID #0x7f03005e
End of managed Android.Content.Res.Resources+NotFoundException stack trace ---
android.content.res.Resources$NotFoundException: Resource ID #0x7f03005e
at android.content.res.Resources.getValue(Resources.java:1125)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2316)
at android.content.res.Resources.getLayout(Resources.java:941)
at android.view.LayoutInflater.inflate(LayoutInflater.java:395)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at md5ec747b7423972841ddca33efeffb70b8.LoginActivity.n_onCreate(Native Method)
at md5ec747b7423972841ddca33efeffb70b8.LoginActivity.onCreate(LoginActivity.java:32)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2225)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2311)
at android.app.ActivityThread.access$600(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5214)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
In mgmain JNI_OnLoad
這裏是我的代碼
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
//RequestedOrientation = Android.Content.PM.ScreenOrientation.Portrait;
// Create your application here
SetContentView(Resource.Layout.Login);
getUser();
//play background video
//videoView = FindViewById<VideoView>(Resource.Id.BackVideo);
IP_Address = FindViewById<EditText>(Resource.Id.IPAddress_Text);
Username_IV = FindViewById<EditText>(Resource.Id.UserName);
Password_IV = FindViewById<EditText>(Resource.Id.Password);
Remember = FindViewById<CheckBox>(Resource.Id.Rembember);
login = FindViewById<Button>(Resource.Id.Login);
//speech = new TextToSpeech(this, this);
IP_Address.Text = "192.168.x.xxx/Sample";
login.Click += login_Click;
//login_Click();
dialog = new ProgressDialog(this);
dialog.Indeterminate = true;
dialog.SetCanceledOnTouchOutside(false);
dialog.SetProgressStyle(ProgressDialogStyle.Spinner);
dialog.SetMessage("Authenticating...");
}
async void login_Click(object sender, EventArgs e)
{
try {
HideKeyBoard();
dialog.Show();
var p = new Dictionary<string, string>();
//speech.Speak("Authenticating", QueueMode.Flush, p);
if (IP_Address.Text.Length <= 0)
{
Toast.MakeText(this, "Please Enter IP Address", ToastLength.Long).Show();
IP_Address.Focusable = true;
//speech.Speak("Please Enter Password", QueueMode.Flush, p);
dialog.Dismiss();
return;
}
if (Username_IV.Text.Length <= 0)
{
Toast.MakeText(this, "Please Enter UserName", ToastLength.Long).Show();
Username_IV.Focusable = true;
//speech.Speak("Please Enter UserName", QueueMode.Flush, p);
dialog.Dismiss();
return;
}
if (Password_IV.Text.Length <= 0)
{
Toast.MakeText(this, "Please Enter Password", ToastLength.Long).Show();
Password_IV.Focusable = true;
//speech.Speak("Please Enter Password", QueueMode.Flush, p);
dialog.Dismiss();
return;
}
else
{
IPAddress = IP_Address.Text.Trim();
string API = "http://" + IPAddress + "/api/Sample/LoginCheck?username=" + Username_IV.Text + "&password=" + this.Encrypt(Password_IV.Text) + "";
HttpClient httpClient = new HttpClient();
string dataResult = await httpClient.GetStringAsync(API);
if (Convert.ToBoolean(dataResult))
{
Toast.MakeText(this, "Login Success", ToastLength.Long).Show();
//speech.Speak("Log in Success", QueueMode.Flush,p);
dialog.Dismiss();
rememberMe();
StartActivity(typeof(HomeActivity));
}
else
{
Toast.MakeText(this, "Login failed", ToastLength.Long).Show();
//speech.Speak("Log in Failed Please Check Your Credentials", QueueMode.Flush, p);
dialog.Dismiss();
}
}
}
catch (Exception ex)
{
Toast.MakeText(this, "Login failed", ToastLength.Long).Show();
dialog.Dismiss();
}
}
發佈您在這裏編碼。 –
我發佈了我的代碼。 –
我在這行SetContentView(Resource.Layout.Login); –