我有个问题。我想使用布局来设计这个 ArcTimerActivity。当我更改setContentView(cv)
为setContentView(R.layout.arc_timer_activity)
它不起作用时。(我不是程序员,所以对我来说并不容易)
public class ArcTimerActivity extends Activity implements Runnable, View.OnClickListener, View.OnLongClickListener {
private ArcTimerView cv = null;
private Thread t = null;
private boolean run_thread = false;
private int run_thread_fps = 50; // Max 1000
private IntervalSession is;
private final int MENU_PREFERENCES = 15;
//@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
is = new IntervalSession();
restorePreferences();
cv = new ArcTimerView(this, is);
cv.setOnClickListener(this);
cv.setOnLongClickListener(this);
restoreRunningState(getLastNonConfigurationInstance());
setContentView(cv);
}
....................
如果使用 setContentView(R.layout.arc_timer_activity) - 没有错误,只是黑屏。可能我需要添加或更改以在布局中显示活动?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<View
android:layout_width="fill_parent"
android:layout_height="fill_parent"
></View>
</LinearLayout>