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:
Use 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:
The 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.
Pingback: A to Z Index and Site Map for WordPress | Tek Eye
Pingback: Add a Border to an Android Layout | Tek Eye
Pingback: Different Ways to Code Android Event Listeners | Tek Eye
Pingback: Portrait and Landscape Screen Layouts in Android | Tek Eye
Pingback: Animated Images in Android | Tek Eye
Pingback: Adding State Graphics to an ImageButton with Inkscape | Tek Eye
Pingback: Button and Image Borders in Android with Nine Patch Files | Tek Eye
Pingback: Use the ZXing Barcode Scanner in an Android App | Tek Eye
Pingback: Change the Text Size in an Android Spinner | Tek Eye
HI ,
I need little help on this topic , we need to install or add the apk file from zing in our app
As noted in the comments for the article Use the ZXing Barcode Scanner in an Android App your App can prompt the user to download the ZXing App if it is not installed when your App attempts to read a barcode. Look at the IntentIntegrator.java class in android-integration of the main trunk (http://code.google.com/p/zxing/source/browse/trunk). Basically is uses PackageManager to query for an intent and then prompts to download it. Alternatively the source code is free under the Apache license so grab it from Google Code and refactor the parts you need for your APK.