2017-01-31 3 views
0

저는 Xamarin Android를 처음 사용합니다. GetComponents 옵션에서 AppCompatv7 지원 라이브러리를 설치했습니다.AppCompat v7이 제대로 참조되지 않습니다.

하지만 언제든지 시도해 볼 때마다 프로젝트에 실제로 추가되지 않는 것처럼 인텔리 센스가 없습니다. 아래처럼 : 나는 어셈블리에 자세한 내용을 볼 때

enter image description here

는 아래 같은 옵션과 함께 제공, 그것은 설치되지 않을 수 있습니다 말하던. 그러나 그림에서 볼 수 있듯이, 그것은 내 참조하에 설치됩니다.

enter image description here

나는 아래 그림에서 Add Package을 클릭하면

는 아무 일도 발생하지 않습니다.

코드를 컴파일 할 때 ActionBarActivity 기본 클래스의 함수를 찾을 수 없으므로 프로젝트에 제대로 추가하지 않는 것으로 추측됩니다.

왜 이런 일이 발생하는지 알고 계십니까? 건배

답변

0

사용하여 설치 NuGet 명령 콘솔 :

Install-Package Xamarin.Android.Support.v7.AppCompat -Pre 
0

내가 코드를 컴파일 할 때, 그것은 ActionBarActivity 기본 클래스의 기능을 찾을 수없는, 그래서 그것을 제대로을 추가하지 않는 것 같은데요 내 프로젝트에.

ActionBarActivity은 더 이상 사용되지 않습니다.

Xamarin.Android.Support.v7.AppCompat 패키지를 설치 한 후, 당신은 단순히 AppCompatActivity 대신 ActionBarActivity에서 MainActivity을 상속 할 수 Android.Support.V7.Widget.Toolbar을 사용합니다.

그럼 예를 들어 내 도구 모음은 다음과 같이이다 :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <include android:id="@+id/toolbar" 
      layout="@layout/mytoolbar" /> 
</LinearLayout> 

그리고 마지막으로 당신의 MainActivity의 :

public class MainActivity : AppCompatActivity 
{ 
    protected override void OnCreate(Bundle bundle) 
    { 
     base.OnCreate(bundle); 

     // Set our view from the "main" layout resource 
     SetContentView(Resource.Layout.Main); 

     var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); 
     SetSupportActionBar(toolbar); 
    } 
} 

당신

<android.support.v7.widget.Toolbar 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_height="wrap_content" 
    android:minHeight="?attr/actionBarSize" 
    android:background="?attr/colorPrimary" 
    android:layout_width="match_parent"> 

    <TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/toolbartitile" 
    android:text="Kodej" /> 
</android.support.v7.widget.Toolbar> 

이 같은 Main 레이아웃이 도구 모음을 포함 코드에서 Android.Support.V7.App을 참조하기 만하면됩니다. 내 데모

using Android.Support.V7.App; 

모든 참조 :

enter image description here

제대로 libs와 설치 한 더 더 인텔리이없는 경우, 당신은 당신의 VS 당신의 앱 가까운 재건하고 다시 시도 할 수 있습니다 .