how to create a class function and call it on other classes that needs the function?
I have this code below, which works okay in a single class.
But is there a way to make a function, so I will just replace the source which is the id of EditText.
So there is no need to copy this code to every class that needs copy function.
final EditText Editsrc = (EditText)findViewById(R.id.XXtxtview);
Button copynPaste = (Button)findViewById(R.id.copynpaste);
final ClipboardManager clipBoard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE);
copynPaste.setOnClickListener(new Button.OnClickListener(){
@SuppressWarnings("deprecation")
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "Copied to clipboard", Toast.LENGTH_SHORT).show();
clipBoard.setText(Editsrc.getText());
}});
Thank you for any help :)