android 操作剪切板

/**
 * @(#) CutActivity.java Created on 2013-5-14
 *
 * Copyright © 2013 深圳企业云科技有限公司  版权所有
 */
package com.demo;

import java.util.Random;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.text.ClipboardManager;
import android.view.View;
import android.widget.Toast;

/**
 * The class <code>CutActivity</code>
 * 
 * @author Feng OuYang
 * @version 1.0
 */
public class CutActivity extends Activity {

	private ClipboardManager cmb;
	
	/* (non-Javadoc)
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.cut);
		super.onCreate(savedInstanceState);
		
		cmb = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
	}
	
	public void copy(View view){
		final Random random = new Random();
		final String r = "" + random.nextLong();
		cmb.setText(r);
		Toast.makeText(this, r, Toast.LENGTH_SHORT).show();
	}
	
}

相关推荐