Posts Tagged ‘view’

Geek Hero Comic

January 27, 2013 1 comment

Welcome to Geek Hero Comic,

Even though the series is under break, and no-one knows when it will come back again, but still, Geek Hero Comic is one of the best comic series about computer geeks.

If you’re already familiar or don’t know about it, just read it once, you will fall in love with it and keep reading every single interesting chapter.

[ Geek Hero Comic ]

version: 1.1

support Android version: 1.6+

Download: Play Store

[ Changelog ]


[version 1.1]

.improve image quality when read in fullscreen mode
.add detailed information for characters


[version 1.0]
.first release
.set GeekHero picture to wallaper
.read story from the very first episode to the last
.view image in fullscreen
.share episode to other apps, like Twitter, Facebook,…
.smooth image view
.add characters’ info

[ Features ]

information on series’ characters

. set wallpapers of some nice GeekHero pictures.

. read and load all chapters at the same time

. support reading in fullscreen mode

. start reading from last read chapter.

. smooth image viewer

[ Screenshots ]













Pete Houston

Using WebView as a Image Zoom View control

September 18, 2011 12 comments

Well, the built-in Google Android has supported for developers lots of things; however, many still don’t know how to make uses the best out of it. One example is about WebView control.

Reference on WebView control on Google Android Developers’ Page

Most of developers just know “WebView is a control that supports the functionality to browse and surf webs.” Yes, that’s totally true! But, hang on…what does it mean specifically?

Think of it! Just like any other browsers, Firefox, IE, Opera or Safari.. what are things  could be displayed on a web browser? – I say “HTML code“, that’s right, for developers. What are the things wrapped around by HTML code? – I say “lots of text and images“.

Hey dude, stop right there. “Text and Images” are things can be displayed seperatedly on a web browser. Hence, for an open and creative minds, by using WebView control, developers can create a simple application like: Text Reader or Image Viewer. That’s true! So for simple application, you don’t have to customize or create any complicated control, WebView control is a good option.

Just for a fun introduction, let’s head to our goal, make use of WebView as an Image Zoom View control.

The WebView control has supported the built-in functionality of zoom, so we don’t have to re-create an already-existed on.

WebView as Image Zoom View

WebView as Image Zoom View

By using a simple property of WebView, we make use of it:


import android.os.Bundle;
import android.webkit.WebView;

public class MainActivity extends Activity {
    // declare a WebView object first
	WebView mWebView = null;

    public void onCreate(Bundle savedInstanceState) {

        // load view
        mWebView = (WebView)findViewById(;
        // (*) this line make uses of the Zoom control
        // simply, just load an image

It’s cool, isn’t it?

What I want to share with you all actually is that, sometimes we think too complicated while the solution is very simple right in front of our eyes. Just to see it with a clear point of view, you’ll find the best solution!

Hope you have a lot of fun in this article >^o^<



Pete Houston


Categories: Tutorials Tags: , , ,

Take a screenshot of your View

Quick snippet

    View content = findViewById(;
    Bitmap bitmap = content.getDrawingCache();

Pete Houston

Create floating view using FrameLayout

Today, something just poped-up on my mind: how to make some views keep visible on the screen? After doing some searchings I’ve found that it can be achieved by using FrameLayout.

Look up at Android Developers’  Reference on FrameLayout.

I took it in practice: creating a layout containing a TextView and a ListView, in which the TextView is always floating on the top of the screen.

Floating View 1

Floating View 1

This is what it looks like at initial state and when I scroll down the list, the TextView should also stay at the top as well.

Float View 2

Float View 2

As you see, it still stays on top of the screen.

Here a sample of using FrameLayout in order to achieve floating state for View:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android=""
		android:text="FLOATING VIEW - TOP"





This design probably makes your application look cooler.
Hope you like it!

Pete Houston

ViewHolder Pattern – Caching View Efficiently

June 16, 2011 18 comments

A – Yeah! It works!

Yo, we’ve got a list view to display something:

Sample ListView

Sample ListView

This is what people like to write for list adapter:

	public View getView(int position, View convertView, ViewGroup parent) {

		View v = convertView;
		if(v == null) {
			LayoutInflater inflater = LayoutInflater.from(mContext);
			v = inflater.inflate(R.layout.layout_list_item, null);

		TextView txtName = (TextView)v.findViewById(;
		TextView txtMail = (TextView)v.findViewById(;

		Contact entry = mList.get(position);


		return v;

That’s great because it works with no problem and the list displays contents nicely!!!


B – Dig It Out

Let’s see how it works..

+ First time loaded, oh right, it’s null!  Ok, to find our TextView controls, ‘findViewById()‘ is loaded. Great, we’ve got it!

+ Second time loaded,  it must be not null, but ‘findViewById()‘ is loaded. Well, just one time, it’s fine!

+ Next time loaded, it’s absolutely not null, eh, ‘findViewById()‘ is called by default. Eh oh..

+ ……whatever time

+ xxx th time…..something is calling ‘findViewById()‘…so stupid, damn it! But it’s still running fine … _ _!


C – Giving birth to a child: ViewHolder

You may see the problem, too. When the list is too big, containing lots of rows, then the calling of ‘findViewById()‘ everytime will impact slightly to your application performance, even though, it’s still working fine; however, it’s quite risky since it might be dead at some unexpected point.

This is one of most common problem, it is! Hence, from somewhere, the idea of ViewHolder pattern was created to improve this current situation.

	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		if(v == null) {
			LayoutInflater inflater = LayoutInflater.from(mContext);
			v = inflater.inflate(R.layout.layout_list_item, null);
			ViewHolder holder = new ViewHolder();
			holder.txtName = (TextView)v.findViewById(;
			holder.txtMail = (TextView)v.findViewById(;

		Contact entry = mList.get(position);
		if(entry != null) {
			ViewHolder holder = (ViewHolder)v.getTag();
		return v;


	static class ViewHolder {
		TextView txtName;
		TextView txtMail;

The ViewHolder object is static, once created, it will cache all things inside. Therefore, we can avoid calling ‘findViewById()‘ on resource everytime.


D – Note

– Something works doesn’t mean it’s the best. Even if it’s fine, it might contain some invisible problems.

– Use ViewHolder pattern whenever possible to cache data!


E – Final Words

– Just something I’ve learned and wanna share to everyone.

– Feel free to comment, suggest and request; I’m here to listen to everyone’s voice 🙂

– Free to share, free to take!



Pete Houston

Use View.tag mechanism for caching view

June 16, 2011 1 comment

This is an interesting caching alternative to ViewHolder pattern.

protected Object getViewHandle(View aParentView, int aViewToFind) {
	Object v = aParentView.getTag(aViewToFind);
	if (v==null) {
		v = aParentView.findViewById(aViewToFind);
	return v;

The sample usage:

TextView tv = (TextView)getViewHandle(itemVi<wbr>ew,;

This code is written by: Uncle Code Monkey at Android ViewHolder discussion

The original post from his blog.



Pete Houston

Categories: Tricks & Tips Tags: , , , ,