我試圖啓動一個Android的活動名稱「TheGame」從一個按鈕活動「SelectionFragment」誰的ID是「startGame」 的SelectionFragment文件的公共類:意圖開始活動不工作
public class SelectionFragment extends Fragment {
這是包含意向代碼:
public void startTheGame (View view) {
Intent intent = new Intent(this, TheGame.class);
startActivity(intent);
}
而這正是我的清單文件看起來像:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.alexlamond.higherorlower"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/highlowlogo"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.alexlamond.higherorlower.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>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/app_id" />
<activity android:name="com.facebook.LoginActivity" >
</activity>
<activity
android:name="com.alexlamond.higherorlower.TheGame"
android:label="@string/title_activity_the_game" >
</activity>
</application>
我的問題是,意圖將無法正常工作,當我到Eclipse的如何解決它的建議,它說:
構造意圖(SelectionFragment,類)是未定義
您是否收到錯誤? – buczek
我們只能猜測,因爲你沒有告訴我們問題是什麼。我的猜測是你在onClickListener中調用了這個,在這種情況下用'替換'this''這個' –
Simon
對不起@Simon,我現在補充! – Alex