14.01.2013 Views

Android™ Application Development - Bahar Ali Khan

Android™ Application Development - Bahar Ali Khan

Android™ Application Development - Bahar Ali Khan

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Figure 4-2<br />

Chapter 4: Creating User Interfaces<br />

1. Create a new TodoListItemView class that extends TextView. Include a stub for overriding the<br />

onDraw method, and implement constructors that call a new init method stub.<br />

package com.paad.todolist;<br />

import android.content.Context;<br />

import android.content.res.Resources;<br />

import android.graphics.Canvas;<br />

import android.graphics.Paint;<br />

import android.util.AttributeSet;<br />

import android.widget.TextView;<br />

public class TodoListItemView extends TextView {<br />

}<br />

public TodoListItemView (Context context, AttributeSet ats, int ds) {<br />

super(context, ats, ds);<br />

init();<br />

}<br />

public TodoListItemView (Context context) {<br />

super(context);<br />

init();<br />

}<br />

public TodoListItemView (Context context, AttributeSet attrs) {<br />

super(context, attrs);<br />

init();<br />

}<br />

private void init() {<br />

}<br />

@Override<br />

public void onDraw(Canvas canvas) {<br />

// Use the base TextView to render the text.<br />

super.onDraw(canvas);<br />

}<br />

83

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!