Issue
I created a basic SQLite Xamarin Android application using the following tutorial: https://www.c-sharpcorner.com/article/xamarin-android-sqlite-database/.
I used almost the same code from the site, but I modified it to suit my needs.
However, the app is not building, the errors I get are:
- Error CS0117 'Resource.Id' does not contain a definition for 'add_date_input'
- Error CS0117 'Resource.Id' does not contain a definition for 'add_save'
- Error CS0117 'Resource.Layout' does not contain a definition for 'Main'
- Error CS0117 'Resource.Layout' does not contain a definition for 'AddReminder'
and so on (all errors of same type)...
My main.axml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px">
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/addReminder" />
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/reminder_listview" />
</LinearLayout>
My MainActivity.cs:
using Android.App;
using Android.Widget;
using Android.OS;
using RemindersDBModel;
using RemindersDBHelper;
using System.Collections.Generic;
using RemindifyListViewAdapter;
using System;
using Android;
namespace ReminderMain
{
[Activity(Label = "Reminder", MainLauncher = true)]
public class MainActivity : Activity
{
Button addReminderBtn;
ListView listView;
List<DBModel> listSource = new List<DBModel>();
DBHelper db;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Main);
db = new DBHelper();
db.createDatabase();
addReminderBtn = FindViewById<Button>(Resource.Id.addReminder);
addReminderBtn.Click += (sender, e) =>
{
StartActivity(typeof(AddReminderActivity));
};
listView.ItemClick += ListView_ItemClick;
loadReminders();
}
private void loadReminders()
{
listSource = db.selectTable();
var adapter = new ListViewAdapter(this, listSource);
listView.Adapter = adapter;
}
}
}
What have I tried till now:
- Cleaning and rebuilding the solution
- Deleting contents of "Resource.Designer.cs"
- Reinstalling Android SDKs
- Adding
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> <AndroidResgenClass>Resource</AndroidResgenClass>to the Reminder.csproj
Any ideas to fix this problem?
Thanks in advance. Regards
Solution
Visual Studio's compiler sometimes will make some mistakes.
Try to delete the bin and obj folder, and restart your VS.
Answered By - Robbit
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.