我在舊帖子上經歷了類似的問題..糾正了它們。仍然收緊力量關閉問題。請幫忙。Android應用程序部隊即將關閉,因爲我在模擬器上打開它
以下哪項是正確的?
Button continueButton = (Button) findViewById(R.id.continue_button);
或
View continueButton = findViewById(R.id.continue_button);
,什麼是它們之間的區別?
package org.example.sudoku;
import android.os.Bundle;
import android.view.View.OnClickListener;
import android.app.Activity;
import android.view.Menu;
import android.widget.Button;
public class Sudoku extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button continueButton = (Button) findViewById(R.id.continue_button);
continueButton.setOnClickListener((OnClickListener) this);
Button aboutButton = (Button)findViewById(R.id.about_button);
aboutButton.setOnClickListener((OnClickListener) this);
Button newButton = (Button)findViewById(R.id.new_game_button);
newButton.setOnClickListener((OnClickListener) this);
Button exitButton = (Button)findViewById(R.id.exit_button);
exitButton.setOnClickListener((OnClickListener) this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
你有關於力量關閉的堆棧跟蹤? –
查看'LogCat'確切的例外情況,這將有助於查明問題。以上兩點都是正確的,取決於你想做什麼(通常是第一個)。 –
檢查logcat是否拋出異常。 –