簡體   English   中英

Monodroid-無法開始新的活動/意圖

[英]Monodroid - Cant start new Activity/Intent

我正在使用Monodroid制作應用程序,並且試圖開始一項新活動。

以下是我用來啟動新活動的代碼

var second = new Intent(this, typeof(CreateVehicle));
        StartActivity(second);

這是“創建車輛”活動

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

namespace BoostITAndroid.Android
{
[Activity(Label = "My Activity")]
public class CreateVehicle : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        // Create your application here
    }
}
}

我的問題是我無法運行該應用程序,因為意圖是CreateVehicle在紅色底線下面,並且它說它不存在。

<activity 
        android:name="YourPackageName.SecondActivityNameOnly"
        /> 

給你AndroidManifest.xml

它應該看起來像這樣:

     <activity
     android:name="com.webview.MainActivity"
     android:label="@string/app_name" >
     <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>
    <activity 
    android:name="YourPackageName.SecondActivityNameOnly"
    />

我發現清單出現問題時,只需對項目進行簡單清理就可以解決問題。

我看到兩個可能的問題:1. CreateVehicle活動缺少SetContentView方法; 2.可能您在另一個名稱空間中有CreateVehicle活動

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM