1
대화 상자 창을 여는 옵션 메뉴 항목을 사용할 수 있습니까? 여기에 내가 가진 무엇 : 나는 점수 옵션 버튼을 선택하면Android : 옵션 메뉴에서 맞춤 팝업 대화 상자 열기
public class main extends Activity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int score;
SharedPreferences stats = getSharedPreferences("TRHprefs", MODE_WORLD_READABLE);
score = stats.getInt("score", 0);
switch (item.getItemId()) {
case R.id.score:
Context mContext = getApplicationContext();
Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.options_menu);
dialog.setTitle("Hero Stats");
TextView b10 = (TextView) dialog.findViewById(R.id.tolevel);
b10.setText("Score: " + score);
dialog.setCancelable(true);
dialog.show();
break;
case R.id.options:
//Options
break;
case R.id.quit:
//Quit
break;
}
return true;
}
}
는 응용 프로그램의 힘은 닫습니다. 어떤 아이디어?
logcat 출력을 제공해 주실 수 있습니까? 그냥 입력하지 않고 그냥 추측 할 수 있습니까? – EpicOfChaos