Adding Additional Activity .cs and Layout axml Using Visual Studio 2015.
I'm very new to Xamarin and Android development, but have been a developer for a few years using VB and now C#. I have a simple app on Android 4.2 that is getting more complicated as I go along. The simple matter us that I want to add an additional GpsAction.cs and corresponding Gps.axml layout to the project. It seems impossible to find the right combination syntax to achive this. I have a mainActivity with main.axml. In VS 2015 it's very simple to add new but I keep getting "resource.id does not contain a definition for" I would really appreciate your help with this
namespace AddCam
{
[Activity(Label = "GpsActivity")]
public class GpsActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.GpsLayout);
string c = FindViewById<TextView>(**Resource.Id.textView1**).Text;
// Create your application here
}
}
My problem was I was trying to debug Xamarin Android project (native) using Xamarin Live Player, connecting using USB cable and selecting my device for debugging solved the problem
Cleared Main.axml page and Reset and it is working.
Make sure your axml is well formed and rebuild the solution it should work, if you continue facing the same issue then remove axml and add it again then build the solution.
(VS 2019) I did the previous solutions and nothing, I had the same problem and the solution for me was to remove '&' from the text of TextView, I was trying to Set the text to "text&text" even &&(I though it was like mnemonics as in WindowsForms) didn't work so I had to remove it and it fixed.