سورس یادم رفت
package com.jadvalzarb;
import java.util.Random;
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class JadvalZarb extends Activity {
Button dokmeh1;
Button dokmeh2;
Button dokmeh3;
Button dokmeh4;
Button dokmeh5;
Button dokmeh6;
Button dokmeh7;
Button dokmeh8;
Button dokmeh9;
Button dokmeh10;
Button dokmeh11;
EditText result;
int str1 = 1;
int str2 = 2;
int str3 = 3;
int str4 = 4;
int str5 = 5;
int str6 = 6;
int str7 = 7;
int str8 = 8;
int str9 = 9;
int str10 = 10;
int rnd = 1;
int num=0;
Random r = new Random();
int index = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_jadval_zarb);
result = (EditText) findViewById(R.id.editText1);
dokmeh1 = (Button) findViewById(R.id.button1);
dokmeh2 = (Button) findViewById(R.id.button2);
dokmeh3 = (Button) findViewById(R.id.button3);
dokmeh4 = (Button) findViewById(R.id.button4);
dokmeh5 = (Button) findViewById(R.id.button5);
dokmeh6 = (Button) findViewById(R.id.button6);
dokmeh7 = (Button) findViewById(R.id.button7);
dokmeh8 = (Button) findViewById(R.id.button8);
dokmeh9 = (Button) findViewById(R.id.button9);
dokmeh10 = (Button) findViewById(R.id.button10);
dokmeh11 = (Button) findViewById(R.id.button11);
int min = 1;
int max = 10;
int ar[] = {0,0,0,0,0,0,0,0,0,0,0};
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
//listOfString;
dokmeh1.setText(String.valueOf(rnd));
str1 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh2.setText(String.valueOf(rnd));
str2 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh3.setText(String.valueOf(rnd));
str3 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh4.setText(String.valueOf(rnd));
str4 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh5.setText(String.valueOf(rnd));
str5 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh6.setText(String.valueOf(rnd));
str6 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh7.setText(String.valueOf(rnd));
str7 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh8.setText(String.valueOf(rnd));
str8 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh9.setText(String.valueOf(rnd));
str9 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh10.setText(String.valueOf(rnd));
str10 = rnd;
dokmeh11.setText("R E F R E S H");
dokmeh1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(num==0)
{
result.setText(str1+"*");
num = str1;
}else
{
result.setText(String.valueOf(result.getText())+st r1);
float z = num * str1;
result.setText(String.valueOf(result.getText())+" = "+String.valueOf((int)z));
num=0;
}
//Getting first & second values and passing to show result
}
});
dokmeh2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(num==0)
{
result.setText(str2+"*");
num = str2;
}else
{
result.setText(String.valueOf(result.getText())+st r2);
float z = num * str2;
result.setText(String.valueOf(result.getText())+" = "+String.valueOf((int)z));
num=0;
}
//Getting first & second values and passing to show result
}
});
dokmeh3.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(num==0)
{
result.setText(str3+"*");
num = str3;
}else
{
result.setText(String.valueOf(result.getText())+st r3);
float z = num * str3;
result.setText(String.valueOf(result.getText())+" = "+String.valueOf((int)z));
num=0;
}
//Getting first & second values and passing to show result
}
});
dokmeh4.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(num==0)
{
result.setText(str4+"*");
num = str4;
}else
{
result.setText(String.valueOf(result.getText())+st r4);
float z = num * str4;
result.setText(String.valueOf(result.getText())+" = "+String.valueOf((int)z));
num=0;
}
//Getting first & second values and passing to show result
}
});
dokmeh5.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(num==0)
{
result.setText(str5+"*");
num = str5;
}else
{
result.setText(String.valueOf(result.getText())+st r5);
float z = num * str5;
result.setText(String.valueOf(result.getText())+" = "+String.valueOf((int)z));
num=0;
}
//Getting first & second values and passing to show result
}
});
dokmeh6.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(num==0)
{
result.setText(str6+"*");
num = str6;
}else
{
result.setText(String.valueOf(result.getText())+st r6);
float z = num * str6;
result.setText(String.valueOf(result.getText())+" = "+String.valueOf((int)z));
num=0;
}
//Getting first & second values and passing to show result
}
});
dokmeh7.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(num==0)
{
result.setText(str7+"*");
num = str7;
}else
{
result.setText(String.valueOf(result.getText())+st r7);
float z = num * str7;
result.setText(String.valueOf(result.getText())+" = "+String.valueOf((int)z));
num=0;
}
//Getting first & second values and passing to show result
}
});
dokmeh8.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(num==0)
{
result.setText(str8+"*");
num = str8;
}else
{
result.setText(String.valueOf(result.getText())+st r8);
float z = num * str8;
result.setText(String.valueOf(result.getText())+" = "+String.valueOf((int)z));
num=0;
}
//Getting first & second values and passing to show result
}
});
dokmeh9.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(num==0)
{
result.setText(str9+"*");
num = str9;
}else
{
result.setText(String.valueOf(result.getText())+st r9);
float z = num * str9;
result.setText(String.valueOf(result.getText())+" = "+String.valueOf((int)z));
num=0;
}
//Getting first & second values and passing to show result
}
});
dokmeh10.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(num==0)
{
result.setText(str10+"*");
num = str10;
}else
{
result.setText(String.valueOf(result.getText())+st r10);
float z = num * str10;
result.setText(String.valueOf(result.getText())+" = "+String.valueOf((int)z));
num=0;
}
//Getting first & second values and passing to show result
}
});
dokmeh11.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
rf();
//Getting first & second values and passing to show result
}
});
}
public void rf()
{
num=0;
result = (EditText) findViewById(R.id.editText1);
result.setText("");
dokmeh1 = (Button) findViewById(R.id.button1);
dokmeh2 = (Button) findViewById(R.id.button2);
dokmeh3 = (Button) findViewById(R.id.button3);
dokmeh4 = (Button) findViewById(R.id.button4);
dokmeh5 = (Button) findViewById(R.id.button5);
dokmeh6 = (Button) findViewById(R.id.button6);
dokmeh7 = (Button) findViewById(R.id.button7);
dokmeh8 = (Button) findViewById(R.id.button8);
dokmeh9 = (Button) findViewById(R.id.button9);
dokmeh10 = (Button) findViewById(R.id.button10);
int min = 1;
int max = 10;
int ar[] = {0,0,0,0,0,0,0,0,0,0,0};
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
//listOfString;
dokmeh1.setText(String.valueOf(rnd));
str1 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh2.setText(String.valueOf(rnd));
str2 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh3.setText(String.valueOf(rnd));
str3 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh4.setText(String.valueOf(rnd));
str4 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh5.setText(String.valueOf(rnd));
str5 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh6.setText(String.valueOf(rnd));
str6 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh7.setText(String.valueOf(rnd));
str7 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh8.setText(String.valueOf(rnd));
str8 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh9.setText(String.valueOf(rnd));
str9 = rnd;
rnd = r.nextInt(max - min + 1) + min;
while(ar[rnd] !=0)
{
rnd = r.nextInt(max - min + 1) + min;
}
ar[rnd] = rnd;
dokmeh10.setText(String.valueOf(rnd));
str10 = rnd;
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_jadval_z arb, menu);
return true;
}
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="21dp"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/editText1"
android:layout_below="@+id/editText1"
android:layout_marginTop="34dp"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_centerHorizontal="true"
android:text="Button" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button2"
android:layout_alignBottom="@+id/button2"
android:layout_alignLeft="@+id/editText1"
android:text="Button" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_below="@+id/button1"
android:layout_marginTop="22dp"
android:text="Button" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button4"
android:layout_alignRight="@+id/button2"
android:text="Button" />
<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button5"
android:layout_alignRight="@+id/button3"
android:text="Button" />
<Button
android:id="@+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button4"
android:layout_below="@+id/button4"
android:layout_marginTop="18dp"
android:text="Button" />
<Button
android:id="@+id/button8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button7"
android:layout_alignBottom="@+id/button7"
android:layout_alignRight="@+id/button5"
android:text="Button" />
<Button
android:id="@+id/button9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button8"
android:layout_alignBottom="@+id/button8"
android:layout_alignLeft="@+id/button6"
android:text="Button" />
<Button
android:id="@+id/button10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button8"
android:layout_below="@+id/button8"
android:layout_marginTop="17dp"
android:text="Button" />
<Button
android:id="@+id/button11"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="38dp"
android:text="Button" />
</RelativeLayout>