December 18th, 2011, 06:43 PM
|
#1 (permalink)
|
|
New Member
Join Date: Dec 2011
Posts: 1
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
|
Help a New Developer with a Simple Problem?
Hello! I just started android development, so I don't fully understand all of the jargon I type...
I came across a set of tutorials that described how to create and use radio buttons to change the gravity and style of text.
Here is my code:
package com.androidbook.myfirstandroidapp;
import android.app.Activity;[...]
public class tutorialOne extends Activity implements OnCheckedChangeListener{
TextView textOut;
EditText getInput;
RadioGroup Gunit;
RadioGroup Sunit;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.tutorial1);
textOut = (TextView) findViewById(R.id.tvGetInput);
getInput = (EditText) findViewById(R.id.etInput);
Button ok = (Button) findViewById(R.id.bOK);
Gunit = (RadioGroup) findViewById(R.id.rgGravity);
Sunit = (RadioGroup) findViewById(R.id.rgStyle);
Gunit.setOnCheckedChangeListener(this);
ok.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
textOut.setText(getInput.getText());
}
});
}
public void onCheckedChanged(RadioGroup group, int checkedId) {
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;
case R.id.rbNormal:
textOut.setTypeface(null, Typeface.NORMAL);
break;
case R.id.rbBold:
textOut.setTypeface(null, Typeface.BOLD);
break;
case R.id.rbItalics:
textOut.setTypeface(null, Typeface.ITALIC);
break;
}
}
}
The "tutorialOne" part above is an error according to Eclipse: "The type tutorialOne must implement the inherited abstract method RadioGroup.OnCheckedChangeListener.onCheckedChange d(RadioGroup, int)"
I tried to use the quick fix but another error came up: "Can not implement the missing methods, either due to compile errors or the projects build path does not resolve all dependencies."
What can I do?
|
|
|