Copying Code from the Articles

Many of our articles will have code listings, they will appear like this piece of code here (handling a button click in an Android App using an anonymous inner class).

[code lang=”java”]
public class main extends Activity {
@Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
findViewById(R.id.button1).setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
  Button btn = (Button)arg0;
 TextView tv = (TextView) findViewById(R.id.textview1);
 tv.setText("You pressed " + btn.getText());
}
});
}
}
[/code]

When you move the pointer over the code a toolbar appears, use these icons to copy the code:

Copy Code IconUse the copy to clipboard icon to copy the code to the clipboard. On some operating systems it will not copy the line breaks correctly. Use the view source option.

Or:

Code Source IconThe view source icon displays the raw source code, on some operating systems this may be better for copying the code, click the icon, select the code in the box that appears and use the context menu to copy it.

Once the code is copied it can be pasted into your own files.

11 thoughts on “Copying Code from the Articles

  1. Pingback: A to Z Index and Site Map for WordPress | Tek Eye

  2. Pingback: Add a Border to an Android Layout | Tek Eye

  3. Pingback: Different Ways to Code Android Event Listeners | Tek Eye

  4. Pingback: Portrait and Landscape Screen Layouts in Android | Tek Eye

  5. Pingback: Animated Images in Android | Tek Eye

  6. Pingback: Adding State Graphics to an ImageButton with Inkscape | Tek Eye

  7. Pingback: Button and Image Borders in Android with Nine Patch Files | Tek Eye

  8. Pingback: Use the ZXing Barcode Scanner in an Android App | Tek Eye

  9. Pingback: Change the Text Size in an Android Spinner | Tek Eye

Leave a Reply

Your email address will not be published. Required fields are marked *

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.