package com.example.mapdemo;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import com.example.mapdemo.view.FeatureView;
/**
* The main activity of the API library demo gallery.
* <p>
* The main layout lists the demonstrated features, with buttons to launch them.
*/
public final class MainActivity extends ListActivity {
/**
* A simple POJO that holds the details about the demo that are used by the List Adapter.
*/
private static class DemoDetails {
/**
* The resource id of the title of the demo.
*/
private final int titleId;
/**
* The resources id of the description of the demo.
*/
private final int descriptionId;
/**
* The demo activity's class.
*/
private final Class<? extends FragmentActivity> activityClass;
public DemoDetails(
int titleId, int descriptionId, Class<? extends FragmentActivity> activityClass) {
super();
this.titleId = titleId;
this.descriptionId = descriptionId;
this.activityClass = activityClass;
}
}
有兩件事我覺得我需要更好地理解何時涉及到這段代碼。首先,我試圖確定的確切含義:使用super();在Java中
private final Class<? extends FragmentActivity> activityClass;
其次,我很好奇什麼是用super()調用;因爲當定義DemoDetails時,它被定義爲:
private static class DemoDetails {
那麼在那一點上沒有擴展,所以超級引用了什麼?使用
<? extends >
我從來沒有見過。
在此先感謝...
Java中的所有類都是從'Object'派生的,所以在這種情況下'super()'已經過時了,因爲構造函數已經生成了,所以這行可能在那裏。 –
@MarcoForberg:如果'super()'在這裏沒有被明確地調用,它會被隱式調用。 – jlordo
@MarcoForberg:我很確定;)參見Java語言規範,第12.5節創建新類實例第3點,[鏈接](http://docs.oracle.com/javase/specs/jls/se7/html /jls-12.html#jls-12.5) – jlordo