Wrox Programmer Forums
|
BOOK: Beginning Android Application Development
This is the forum to discuss the Wrox book Beginning Android Application Development by Wei-Meng Lee; ISBN: 978-1-1180-1711-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Android Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 1st, 2012, 09:18 PM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default Btn code not accessible

Given the following code snipet from page 35 of your book
Code:
package net2.learn2develop.Dialog;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import android.app.ProgressDialog;
import android.os.Handler;
import android.os.Message;

public class MainActivity extends Activity {
	CharSequence[] items = { "Google", "Apple", "Microsoft" };
	boolean[] itemsChecked = new boolean [items.length];
	public void OnCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		Button btn = (Button) findViewById(R.id.btn_dialog);
		btn.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				showDialog(0);
				
			}
		});
	}
	
	
}
With the Main.xml file listing as :
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />
    <Button
    android:id="@+id/btn_dialog"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Click to display a dialog" />
</LinearLayout>
I get the following compile error :
btn_dialog can not be resolved or is not a field. This code was cut copied pasted straight into the Android application. This book is a very, very poor book for beginners to say the least. The book doesn't go into enough instructions on a step by step basis on what to do and how to go about doing it. The screen shots with Eclipse with the Android SDK also don't even come close to matching up to what I am running right now, so even creating a new Android project leaves a lot to confusion.
 
Old June 1st, 2012, 09:21 PM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default Other beginners book are much better.

I would also like to say that other beginners books are much easier to understand and their code works right out of the box, unlike yours that the moment you copy it into the Android Main.xml file or the MainActivity Java file doesn't throw a ton of errors like your code does. I have been using Android Apps for Absolute beginners and Android for Dummies and they seem to be guiding me along a lot better on this application development area, much better than your book seems to be doing.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Created a profile but error elements are not accessible hoss BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 February 18th, 2011 04:12 PM
2 Radio btn with one Submit btn, convert to 2 Btn ismailc XSLT 2 August 15th, 2008 07:00 AM
Subs in module not accessible!? LenexaKS ASP.NET 2.0 Basics 4 May 31st, 2007 08:06 AM
accessible forms nclisgo BOOK: Accessible XHTML and CSS Web Sites: Problem Design Solution 0 June 9th, 2005 05:57 AM
Executing main() from a control btn aaadetos Visual C++ 3 November 19th, 2004 06:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.