I have this code for copying to clipboard for API < 11
In my onCreate method :
TextView textView=(TextView)findViewById(R.id.textView1);
registerForContextMenu(textView);
Then override onCreateContextMenu :
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
//user has long pressed your TextView
menu.add(0, v.getId(), 0, "Copy");
//cast the received View to TextView so that you can get its text
TextView textView = (TextView) v;
//place your TextView's text in clipboard
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(textView.getText()); }
and
" android:textIsSelectable="true" " , for API >= 11 ,
How can I use if statement that if user's mobile is API < 11 the first code runs else the second runs ?????