I have to develop 2048 configuration interface design

Source: Internet
Author: User

Of course, unlike us today in the market program 2048 due to rigidity. Life 4x4 panel, today, people. The pressure is arbitrary. All things are in my control. This is cool.

Therefore, we must have a program configuration interface, international practice, on the map:

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvzwnsaxbzzxh5cw==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "/>


This configuration interface mainly completes the following several functions:

1. The dimensions of the game panel can be configured. That's 4x4. 5x5,6x6, in fact, it is possible to continue writing, but. There is also a limit to desire. Almost the same, that's enough.

2, to achieve the goal, you can choose to 1024 on the cool, or 2048 just cool, or 4096 just cool, in fact, can always write down. Old rules Don't push yourself too tightly. Almost the same. Why do you abuse yourself?

3, contact Me. Make an ad for my blog.

Configuration features. Basic write sharedpreferences, this because everyone uses is more, not specifically said

Here is the source code:

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.i D.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", "204    8 "," 4096 "}; } private void Saveconfig () {Editor editor = Config.sp.edit (); Editor.putint (Config.key_gamelines, Integer.parseint (btn Gamelines.gettext (). ToString ()); Editor.putint (Config.key_gamegoal, Integer.parseint (Btngoal.gettext (). ToString    ())); Editor.commit (); } @Override public void OnClick (View v) {switch (V.getid ()) {R.id.btn_gamelines:builder = new alertdialog.b    Uilder (this);    Builder.settitle ("Choose the lines of the game"); Builder.setitems (Gamelineslist, New Dialoginterface.onclicklistener () {@Overridepublic 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 () {@Overridepublic 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;} }}

Above

Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.

I have to develop 2048 configuration interface design

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.