歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android中使用繼承GDActivity出現的問題

Android中使用繼承GDActivity出現的問題

日期:2017/3/1 10:20:03   编辑:Linux編程

最近開始研究Android開發,使用了GreenDroid UI庫,創建Activity如下:

public class MyActivity extends GDActivity{

protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setActionBarContentView(R.layout.main);
}

}

很簡單的一個activity,但卻啟動不了,經過反復的查找原因終於找到解決辦法

需要在AndroidManifest.xml中指定如下:

<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/Theme.GDCatalog"
android:name="com.cvicse.hs.cbxt.cbcx.cApplication" >
<!-- 登陸完畢後用戶展示的主要業務圖標 -->
<activity
android:name="com.cvicse.hs.main.MSAPROJECTActivity"
android:label="@string/app_name" >
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

還需要在cApplication 這個類中做以下修改:

package com.cvicse.hs.cbxt.cbcx;

import com.cvicse.hs.main.MSAPROJECTActivity;

import android.content.Intent;

import greendroid.app.GDApplication;

public class cApplication extends GDApplication {

@Override
public Class<?> getHomeActivityClass() {
// TODO Auto-generated method stub
return MSAPROJECTActivity.class;
}

@Override
public Intent getMainApplicationIntent() {
// TODO Auto-generated method stub
Intent intent = new Intent(getApplicationContext(),MSAPROJECTActivity.class);
return intent;
}

}

問題即可解決

更多Android相關信息見Android 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=11

Copyright © Linux教程網 All Rights Reserved