关于Android中的Lunar lander(内部类)

时间:2010-10-08 12:25:52

标签: android

我对android很新。

对java也很新,所以请随时给我任何建议,我将非常感激。

问题出在lunarlander.java

/** A handle to the thread that's actually running the animation. */
private LunarThread mLunarThread;

/** A handle to the View in which the game is running. */
private LunarView mLunarView;

但是在lunarview.java

class LunarView extends SurfaceView implements SurfaceHolder.Callback {

/** Handle to the application context, used to e.g. fetch Drawables. */
private Context mContext;

/** Pointer to the text view to display "Paused.." etc. */
private TextView mStatusText;


class LunarThread extends Thread

我只学过C和C ++

所以我无法弄清楚为什么我可以调用内部类?

1 个答案:

答案 0 :(得分:1)

可以从同一个包中的任何类访问没有修饰符private或protected的类和字段。我们可以按LunarThread访问LunarView.LunarThread或导入类LunarThread,如LunarLander.java中所做:

import com.example.android.lunarlander.LunarView.LunarThread;

请参阅任何有关Java的参考书。

相关问题