Reputation: 213
Im new to android programming and Im following this tutorial: https://www.youtube.com/watch?v=pZaRNVwKAy4. I followed the tutorial exactly but Eclipse manages to find lots of errors. It says the curly braces are incorrect, yet when I select one, the one it corresponds to lights up and they all form a pair. Furthermore, Eclipse doesn't recognise the variables I declared before the onCreate method. Here is the code:
package com.example.tutorialproject;
import android.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;
public class TutorialOne extends Activity implements OnCheckedChangeListener{
TextView = textOut;
EditText = textIn;
RadioGroup = gravityG, styleG;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.tutorial1);
textOut = (TextView) findViewById(R.id.tvChange);
textIn = (EditText) findViewById(R.id.editText1);
gravityG = (RadioGroup) findViewById(R.id.rgGravity);
styleG = (RadioGroup) findViewById(R.id.rgStyle);
Button gen = (Button) findViewById(R.id.bGenerate);
gen.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
textOut.setText(textIn.getText());
}
});
}
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// TODO Auto-generated method stub
switch (checkedId){
case R.id.rbLeft:
textOut.setGravity(Gravity.LEFT);
break;
case R.id.rbCenter:
textOut.setGravity(Gravity.CENTER);
break;
case R.id.rbRight:
textOut.setGravity(Gravity.RIGHT);
break;
}
}
}
Cut/paste and clean doesn't work, I already tried it. Anyone any idea what might be the problem? Sorry for the long post.
Thanks in advance
Upvotes: 1
Views: 69
Reputation: 157487
TextView = textOut;
EditText = textIn;
RadioGroup = gravityG, styleG;
get rid of the =
. You can find here a nice introduction to the member variables
Upvotes: 3