class tutorialOne extends Activity implements OnCheckedChangeListener {
TextView textOut;
EditText textIn;
RadioGroup gravityG, styleG;
private String alignment;
@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);
gravityG.setOnCheckedChangeListener(this);
styleG = (RadioGroup) findViewById(R.id.rgStyle);
styleG.setOnCheckedChangeListener(this);
Button gen = (Button) findViewById(R.id.bGenerate);
gen.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (alignment.equals("left")) {
textOut.setGravity(Gravity.LEFT);
} else if (alignment.equals("right")) {
textOut.setGravity(Gravity.RIGHT);
} else {
textOut.setGravity(Gravity.CENTER);
}
textOut.setText(textIn.getText());
}
});
}
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// TODO Auto-generated method stub
switch (checkedId) {
case R.id.rbLeft:
alignment = "left";
break;
case R.id.rbRight:
alignment = "right";
break;
case R.id.rbCenter:
alignment = "center";
break;
}
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en