我曾经读过一个教程,但从那以后我的手机被 XBOX 刷掉了,所以我把它弄丢了。我希望在 MainActivity 上有一个按钮来打开一个 AlertDialog 框,说明应用程序信息,例如版本号、关于当前版本、这个是哪个 android 版本等。
package com.apw.games.rpg.medieval;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.content.*;
import android.util.*;
import android.graphics.*;
public class MainActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override public void onNothingSelected(AdapterView<?> parent) {
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu); return true; }
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.quit:
Intent intent = new Intent(this, Exit.class);
startActivity(intent);
return true;
case R.id.new_game:
Intent i = new Intent(this, New_Game.class);
startActivity(i);
return true;
case R.id.visit_site:
Intent inte = new Intent(this, Site.class);
startActivity(inte);
return true;
default: return super.onOptionsItemSelected(item);
}}