2016-12-27 10 views
0

私はVS 2015 EnterpriseとXamarinで新しいアンドロイドプロジェクトを作成し、ウィジェットを追加しました。私は、プロジェクトをビルドして実際のアンドロイド4.4デバイスで実行するたびに空のフォームを取得しています。アンドロイド4.1を使用してコンパイルします。ここ Xamarinアンドロイドコンパイルされたアプリが空です

App screenshot

はmain.axmlコードです:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:gridSpec="1|8|#0093eeff|K:#ee8700ff:16,l:72,l:16,r|S:#83ee00ff:16,0,l:16,56,l:16,0,r" 
    android:background="#9a50ea" 
    android:minWidth="25px" 
    android:minHeight="25px"> 
<LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="0dip" 
      android:layout_weight="10" 
      android:background="#9a50ea"> 
      <Button 
       android:layout_width="0dip" 
       android:layout_height="wrap_content" 
       android:text="آگهی جدید" 
       android:id="@+id/button5" 
       android:layout_weight="20" 
       android:background="@android:color/transparent" 
       android:textColor="@android:color/white" 
       android:drawableRight="@drawable/ic_add_white_24dp" 
       android:clickable="true" /> 
      <TextView 
       android:layout_width="0dip" 
       android:layout_height="match_parent" 
       android:text="صفحه اصلی" 
       android:id="@+id/button6" 
       android:layout_weight="35" 
       android:background="@android:color/transparent" 
       android:textColor="@android:color/white" 
       android:gravity="center_vertical" 
       fontPath="fonts/Shabnam.ttf" /> 
      <ImageView 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:id="@+id/imageView" 
       android:layout_weight="10" 
       android:src="@drawable/logo" 
       android:clickable="true" /> 
     </LinearLayout> 
     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="0dip" 
      android:layout_weight="10" 
      android:gravity="right" 
      android:layout_gravity="right" 
      android:background="#9a50ea"> 
      <Button 
       android:layout_width="0dip" 
       android:layout_height="wrap_content" 
       android:text="چسپ من" 
       android:id="@+id/button" 
       android:layout_weight="25" 
       android:drawableTop="@drawable/ic_person_white_24dp" 
       android:background="@android:color/transparent" 
       android:textColor="@android:color/white" /> 
      <Button 
       android:layout_width="0dip" 
       android:layout_height="wrap_content" 
       android:text="جستجو" 
       android:id="@+id/button3" 
       android:layout_weight="25" 
       android:drawableTop="@drawable/ic_search_white_24dp" 
       android:background="@android:color/transparent" 
       android:textColor="@android:color/white" /> 
      <Button 
       android:layout_width="0dip" 
       android:layout_height="wrap_content" 
       android:text="دسته‌بندی‌ها" 
       android:id="@+id/button2" 
       android:layout_weight="25" 
       android:drawableTop="@drawable/ic_list_white_24dp" 
       android:background="@android:color/transparent" 
       android:textColor="@android:color/white" /> 
      <Button 
       android:layout_width="0dip" 
       android:layout_height="wrap_content" 
       android:text="صفحه اصلی" 
       android:id="@+id/button4" 
       android:layout_weight="25" 
       android:drawableTop="@drawable/ic_home_white_24dp" 
       android:background="@android:color/transparent" 
       android:textColor="@android:color/white" /> 
     </LinearLayout> 
    </LinearLayout> 
</LinearLayout> 

主な活動ファイル:

using Android.App; 
using Android.Widget; 
using Android.OS; 
using Android.Graphics; 
using UK.CO.Chrisjenx.Calligraphy; 

namespace Chasp 
{ 
    [Activity(Label = "Chasp", MainLauncher = true, Icon = "@drawable/icon")] 
    public class MainActivity : Activity 
    { 
     protected override void OnCreate(Bundle bundle) 
     { 
      base.OnCreate(bundle); 
     } 
    } 
} 

ヘルプ/ Xamarin /オープンログファイル:あなたはまだ設定する必要が

Xamarin.VisualStudio.Android.MonoAndroidFlavoredProject Information: 0 : [2016-12-27 11:47:42.8980] designer model checker: DocumentSaved 
Xamarin.VisualStudio.Android.MonoAndroidFlavoredProject Information: 0 : [2016-12-27 11:48:01.0096] designer model checker: Build 
Xamarin.VisualStudio.ActivationManager Error: 0 : [2016-12-27 11:48:01.1106] Couldn't synchronize/copy Java.Interop.dll 
System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. 

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost) 
    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) 
    at Xamarin.AndroidDesigner.DesignerProject.SynchronizeDirectoryRecursive(String src, String dst) 
Xamarin.VisualStudio.ActivationManager Error: 0 : [2016-12-27 11:48:01.1364] Couldn't synchronize/copy mscorlib.dll 
System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. 

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost) 
    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) 
    at Xamarin.AndroidDesigner.DesignerProject.SynchronizeDirectoryRecursive(String src, String dst) 
Xamarin.VisualStudio.ActivationManager Error: 0 : [2016-12-27 11:48:01.1454] Couldn't synchronize/copy System.Collections.Concurrent.dll 
System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. 

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost) 
    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) 
    at Xamarin.AndroidDesigner.DesignerProject.SynchronizeDirectoryRecursive(String src, String dst) 
Xamarin.VisualStudio.ActivationManager Error: 0 : [2016-12-27 11:48:01.1604] Couldn't synchronize/copy System.Collections.dll 
System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. 

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost) 
    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) 
    at Xamarin.AndroidDesigner.DesignerProject.SynchronizeDirectoryRecursive(String src, String dst) 
Xamarin.VisualStudio.ActivationManager Error: 0 : [2016-12-27 11:48:01.1694] Couldn't synchronize/copy System.Core.dll 
System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. 

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost) 
    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) 
    at Xamarin.AndroidDesigner.DesignerProject.SynchronizeDirectoryRecursive(String src, String dst) 
Xamarin.VisualStudio.ActivationManager Error: 0 : [2016-12-27 11:48:01.1774] Couldn't synchronize/copy System.Diagnostics.Debug.dll 
System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. 

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost) 
    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) 
    at Xamarin.AndroidDesigner.DesignerProject.SynchronizeDirectoryRecursive(String src, String dst) 
Xamarin.VisualStudio.ActivationManager Error: 0 : [2016-12-27 11:48:01.1844] Couldn't synchronize/copy System.dll 
System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. 

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost) 
    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) 
    at Xamarin.AndroidDesigner.DesignerProject.SynchronizeDirectoryRecursive(String src, String dst) 
Xamarin.VisualStudio.ActivationManager Error: 0 : [2016-12-27 11:48:01.1934] Couldn't synchronize/copy System.Linq.dll 
System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. 

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost) 
    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) 
    at Xamarin.AndroidDesigner.DesignerProject.SynchronizeDirectoryRecursive(String src, String dst) 
Xamarin.VisualStudio.ActivationManager Error: 0 : [2016-12-27 11:48:01.2249] Couldn't synchronize/copy System.Reflection.dll 
System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. 

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost) 
    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) 
    at Xamarin.AndroidDesigner.DesignerProject.SynchronizeDirectoryRecursive(String src, String dst) 
Xamarin.VisualStudio.ActivationManager Error: 0 : [2016-12-27 11:48:01.2324] Couldn't synchronize/copy System.Reflection.Extensions.dll 
System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. 

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost) 
    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) 
    at Xamarin.AndroidDesigner.DesignerProject.SynchronizeDirectoryRecursive(String src, String dst) 
Xamarin.VisualStudio.ActivationManager Error: 0 : [2016-12-27 11:48:01.2399] Couldn't synchronize/copy System.Runtime.dll 
System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. 

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost) 
    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) 
    at Xamarin.AndroidDesigner.DesignerProject.SynchronizeDirectoryRecursive(String src, String dst) 
Xamarin.VisualStudio.ActivationManager Error: 0 : [2016-12-27 11:48:01.2479] Couldn't synchronize/copy System.Runtime.InteropServices.dll 
System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. 

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost) 
    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) 
    at Xamarin.AndroidDesigner.DesignerProject.SynchronizeDirectoryRecursive(String src, String dst) 
Xamarin.VisualStudio.ActivationManager Error: 0 : [2016-12-27 11:48:01.2579] Couldn't synchronize/copy System.Threading.dll 
System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. 

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost) 
    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) 
    at Xamarin.AndroidDesigner.DesignerProject.SynchronizeDirectoryRecursive(String src, String dst) 
+1

後のOnCreateメソッドでコンテンツとしてレイアウトを設定する必要があります。 OnCreate(バンドル); ' –

+0

OMG!私はこれに2時間を費やし、私はそれを認識しませんでした!ありがとうございました。私はそれを受け入れることができるように質問に答えてください。なぜxamarinは新しいプロジェクトのためにそれを追加しませんか? – l3est

答えて

1

コンテンツは次のようなレイアウトになります。

[Activity(Label = "Chasp", MainLauncher = true, Icon = "@drawable/icon")] 
public class MainActivity : Activity 
{ 
    protected override void OnCreate(Bundle bundle) 
    { 
     base.OnCreate(bundle); 
     SetContentView (Resource.Layout.Main); 
    } 
} 

これはあなたのAXMLファイルをロードし、コンテンツとして設定します。

これはデフォルトでは行われない理由は、UIを構築する方法が複数あるからです。コードで定義することもできます。おそらくこのデフォルトコードは別のプロジェクトテンプレートにあります。とにかく、いつでもすぐにこれを忘れることはありません!あなたの `ベースの後に`;

0

あなたは私はあなたがまだ `SetContentView(Resource.Layout.Main)のようなコンテンツとしてレイアウトを設定する必要があると思う

base.OnCreate(bundle); 
SetContentView (Resource.Layout.Main); 
関連する問題