English 中文(简体)
A. 形成一种简单的经验游戏
原标题:Developing a simple memory game

I m kinda new to Android, now I m developing a very simple game, the logic is described as following: The user sees a 10-digit value after pressing a "Ready" Button. After 5 seconds, the value changes to
* * * * * * * and the user has to enter it in a text field (type "number") below. Under that text field there are 2 Buttons: "Check" and "Give a hint". The check Button compares the user value to original value and changes a TextView according to the result("Correct"/"Incorrect"). The hint Button should show 3 random digits in the original value.

我对这项小应用有一些问题:

  1. I m not sure which type I have to use to show the original value to the user: a TextView, a text field or something else?
  2. How do I force the app to show 3 random digits from the original value in the case when user presses the hint Button?

感谢任何帮助。

最佳回答

页: 1 我不敢确定哪类我必须用来向用户展示原始价值:文本意见、案文领域或其他内容?

本案文将照此办理。

页: 1 当用户对 h子施加压力时,我如何迫使该数字显示3位随机数字?

希望你利用int储存10位数值(原始价值)

1. 形成规模10的阵容

int[] digits = new int[10];

用于将10位数与10位数分开。

int number = 1234567891
for(int i = 0; i < 10; i++){
  digits[i] = number % 2;
  number = number / 10;
}

这将赋予你10个内在价值。

object。 随机值从0-9

Random r = new Random();
int pos1 = r.nextInt(9);

nextInt (int n) Return a pseudo-random coordinatedly distribution int in the half-open range [0, n].

These values are positions from which you are going to retrieve digit from array So this will give you random position between 0 and 9

如果你为第二位数生成随机位置,你应核实这种位置应等于第一。

you can show all 3 digits(fetched from 3 randomly generated positions) in TextView as a hint Hope this will solve your problem

Edited Part Set visibility of Textview to View.GONE something like this private TextView tv;

tv = (TextView)findViewById(R.id.textView01);
tv.setVisibility(View.GONE);

Button btn = (Button)findViewById(R.id.button01);
btn.setOnClickListener(new OnClickListener(){
   public void onClick(View view){
      tv.setVisibility(View.VISIBLE);
   }
});
问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签