zoukankan      html  css  js  c++  java
  • 我必须发展2048配置界面设计

    当然,不像我们今天在市场上节目2048由于刚性。一生4X4面板,今天,人们。压力是任意的。所有的事情都在我的控制。这个很酷。

    因此,我们必须有一个程序的配置界面,国际惯例,在地图上:



    这个配置界面主要完毕以下几个功能:

    1、可配置游戏面板的维数。即4X4。5X5,6X6,事实上继续写下去也是能够的,可是。欲望也是要有限度的啊。差点儿相同就够了

    2、要达到的目标,你能够选择到1024就爽了呢,还是2048才爽,还是4096才爽,事实上也是能够一直写下去的。老规矩。不要把自己逼的太紧了。差点儿相同即可了。虐自己何必呢

    3、Contact Me。给我的博客打个广告啦

    配置功能。基本写入SharedPreferences,这个由于大家使用都比較多了,就不具体说了

    以下是源代码:

    package com.xys.game2048.activity;
    
    import com.xys.game2048.R;
    import com.xys.game2048.config.Config;
    
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.content.DialogInterface;
    import android.content.SharedPreferences;
    import android.content.SharedPreferences.Editor;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    
    public class ConfigPreference extends Activity implements OnClickListener {
    
        private Button btnGameLines;
    
        private Button btnGoal;
    
        private Button btnBack;
    
        private Button btnDone;
    
        private String[] gameLinesList;
    
        private String[] gameGoalList;
    
        private AlertDialog.Builder builder;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
    	setContentView(R.layout.config_preference);
    	initView();
        }
    
        private void initView() {
    	btnGameLines = (Button) findViewById(R.id.btn_gamelines);
    	btnGoal = (Button) findViewById(R.id.btn_goal);
    	btnBack = (Button) findViewById(R.id.btn_back);
    	btnDone = (Button) findViewById(R.id.btn_done);
    	btnGameLines.setText("" + Config.sp.getInt(Config.KEY_GameLines, 4));
    	btnGoal.setText("" + Config.sp.getInt(Config.KEY_GameGoal, 2048));
    	btnGameLines.setOnClickListener(this);
    	btnGoal.setOnClickListener(this);
    	btnBack.setOnClickListener(this);
    	btnDone.setOnClickListener(this);
    	gameLinesList = new String[] { "4", "5", "6" };
    	gameGoalList = new String[] { "1024", "2048", "4096" };
        }
    
        private void saveConfig() {
    	Editor editor = Config.sp.edit();
    	editor.putInt(Config.KEY_GameLines, Integer.parseInt(btnGameLines.getText().toString()));
    	editor.putInt(Config.KEY_GameGoal, Integer.parseInt(btnGoal.getText().toString()));
    	editor.commit();
        }
    
        @Override
        public void onClick(View v) {
    	switch (v.getId()) {
    	case R.id.btn_gamelines:
    	    builder = new AlertDialog.Builder(this);
    	    builder.setTitle("choose the lines of the game");
    	    builder.setItems(gameLinesList, new DialogInterface.OnClickListener() {
    
    		@Override
    		public void onClick(DialogInterface dialog, int which) {
    		    btnGameLines.setText(gameLinesList[which]);
    		}
    	    });
    	    builder.create().show();
    	    break;
    	case R.id.btn_goal:
    	    builder = new AlertDialog.Builder(this);
    	    builder.setTitle("choose the goal of the game");
    	    builder.setItems(gameGoalList, new DialogInterface.OnClickListener() {
    
    		@Override
    		public void onClick(DialogInterface dialog, int which) {
    		    btnGoal.setText(gameGoalList[which]);
    		}
    	    });
    	    builder.create().show();
    	    break;
    	case R.id.btn_back:
    	    this.finish();
    	    break;
    	case R.id.btn_done:
    	    saveConfig();
    	    setResult(RESULT_OK);
    	    this.finish();
    	    break;
    	default:
    	    break;
    	}
        }
    }
    

    以上

    版权声明:本文博主原创文章。博客,未经同意不得转载。

  • 相关阅读:
    【北邮人论坛帖子备份】【心得】20年公考经验分享
    如何写一封国际会议的交流信?
    花呗广告趣图
    《第九个寡妇》读后感
    沟通的五个层次
    部署多功能模块依赖项目中解决的问题
    maven: can't resolve plugin xxxmaven-xxxx-plugin:x.x
    C++编译报错:need 'typename' before 'std::map<T, S>::iterator' because 'std::map<T, S>' is a dependent scope
    详细js中(function(window,document,undefined))的作用
    201509020-js
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/4796782.html
Copyright © 2011-2022 走看看