Android中使用继承GDActivity出现的问题


最近开始研究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.bkjia.com/topicnews.aspx?tid=11

相关内容