문제 설명
xamarin에서 Android 활동 간에 데이터를 전달할 수 없습니다. (Can't pass data between android activities in xamarin)
모든 자습서는 다음과 같습니다.
Intent newMainActivity = new Intent (this, typeof(Activity2));
newMainActivity.PutExtra ("MyData", hT);
StartActivity(newMainActivity);
하지만 이 작업을 수행하려고 할 때 여전히 "Android.App.Activity.Intent는 '속성'이지만 '유형'처럼 사용됩니다"라고 표시됩니다. 두 번째와 세 번째 줄은 정상이지만 첫 번째 줄은 작동하지 않습니다.
Intent newMainActivity = new Intent (this, typeof(Activity2));
오류 ;(
참조 솔루션
방법 1:
Android.App.Activity.Intent is a "Property" so the error is absolutely correct, but you should be using "Android.Content.Intent".
Check your using
section, do you have any using static
statements? If so, try commenting them at and insure that you have a Android.Content
in the using section:
Using Example:
using Android.Content;
Code Example:
var newMainActivity = new Intent (this, typeof(Activity2));
if you have to fully qualify it due to namespace confusion with something you are doing with Activity.Intent
, then:
var newMainActivity = new Android.Content.Intent (this, typeof(Activity2));
(by TrotlOtl、SushiHangover)