7 Replies - 422 Views - Last Post: 03 May 2013 - 08:25 PM Rate Topic: -----

#1 Eddie1975  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 03-May 13

android for dummies....syntax error?

Posted 03 May 2013 - 07:36 PM

Hi all
I'm not doing homework, just trying to learn on my own from the android for dummies book. I keep coming across the same problem. syntax errors. I will attach a screenshot of whats underlined. its weird really, the findViewById is fine on cheeseBox and textView, its probably something simple that Im missing, but Im really new to all of this. I will also paste the entire program down here so yall can see it but please look at the screenshot to see the red underline.
package com.example.pissa;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;


public class MainActivity extends Activity {
	TextView textView;
	CheckBox pepBox, cheeseBox;
	pepBox =
			(CheckBox) findViewById(R.id.checkBox1);
	cheeseBox =
			(CheckBox) findViewById(R.id.checkBox2);
	textView =
			(TextView) findViewById(R.id.textView1);
           }
	
	public void onButton1Click(View view){
		StringBuilder str = new StringBuilder("");
		if (pepBox.isChecked()){
			str.append("Pepperoni" + " ");
		}
		if (cheeseBox.isChecked()){
			str.append("Extra Cheese");}
		if (str.length() == 0) {
			str.append("Plain");
		}
		textView.setText(str);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}


Attached Image

Is This A Good Question/Topic? 0
  • +

Replies To: android for dummies....syntax error?

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: android for dummies....syntax error?

Posted 03 May 2013 - 07:49 PM

I know nothing about Android... and there is actually an Android forum where you should post that type of question.
Anyhow, if ever it can be related, in pure Java

CheckBox

should be

Checkbox
Was This Post Helpful? 0
  • +
  • -

#3 Eddie1975  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 03-May 13

Re: android for dummies....syntax error?

Posted 03 May 2013 - 07:58 PM

ahhh mobile programing. got it. thanks. the CheckBox is correct(from the book anyway). next time I will be a little more observant when i post.
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: android for dummies....syntax error?

Posted 03 May 2013 - 08:01 PM

and post in the good forum
:^:
Was This Post Helpful? 0
  • +
  • -

#5 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 822
  • View blog
  • Posts: 2,529
  • Joined: 29-July 11

Re: android for dummies....syntax error?

Posted 03 May 2013 - 08:05 PM

It is a Java problem. :) Delete line 20, then moves lines 14 through 19 into onCreate().
Was This Post Helpful? 1
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: android for dummies....syntax error?

Posted 03 May 2013 - 08:06 PM

:sleep1:
Was This Post Helpful? 0
  • +
  • -

#7 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 822
  • View blog
  • Posts: 2,529
  • Joined: 29-July 11

Re: android for dummies....syntax error?

Posted 03 May 2013 - 08:09 PM

Wow. I didn't see any of that. It must have been my gui builder throwing me off...

This post has been edited by farrell2k: 03 May 2013 - 08:09 PM

Was This Post Helpful? 0
  • +
  • -

#8 Eddie1975  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 03-May 13

Re: android for dummies....syntax error?

Posted 03 May 2013 - 08:25 PM

View Postfarrell2k, on 03 May 2013 - 08:05 PM, said:

It is a Java problem. :)/>/> Delete line 20, then moves lines 14 through 19 into onCreate().

nailed it dude!!!
this is gonna be a long learning curve for me. but i just learned my first little bit.
thanks so much!!!

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1