-
随机生成的UUID数字
资源介绍
利用UUID生成完全不重复的数字
package com.example.uuid;
import java.util.UUID;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity implements OnClickListener {
private TextView tv;
private Button button1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button1 = (Button) findViewById(R.id.button1);
tv = (TextView) findViewById(R.id.tv);
button1.setOnClickListener(this);
UUID uuid = UUID.randomUUID();
tv.setText(uuid.toString());
}
@Override
public void onClick(View v) {
UUID uuid = UUID.randomUUID();
tv.setText(uuid.toString());
}
}
- 上一篇: Javascript 生成 uuid 函数
- 下一篇: ocr6