책을 보고 따라쓰고 틀린곳이 있나 확인을 해봐도 없는데 도저히 뭐가 문제인지 잘 모르겠더라구염...setOnCheckedChangeListener (new OnCheckedChangeListener() 이부분이 계속 오류나더라구염 제 소스 같은경우는
package com.Cha;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import android.widget.ToggleButton;
public class ChaActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
((Button)findViewById(R.id.btnOpen)).setOnClickListener(listener);
((Button)findViewById(R.id.btnSave)).setOnClickListener(listener);
((ImageButton)findViewById(R.id.btnImg))
.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v){
EditText edit = (EditText)findViewById(R.id.edit);
Toast.makeText(ChaActivity.this,
"Image button click.EditText =" +
edit.getText().toString(),
Toast.LENGTH_SHORT).show();
}
});
((CheckBox)findViewById(R.id.chkAutoSave))
.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v){
Toast.makeText(ChaActivity.this,
"CheckBox is" +
(((CheckBox)v).isChecked()?"checked":"unchecked"),
Toast.LENGTH_SHORT).show();
}
});
((RadioGroup)findViewById(R.id.rdbGp))
.setOnCheckedChangeListener (new OnCheckedChangeListener()
{
public void onCheckedChanged(RadioGroup group, int checkedId) {
//RadioButton rdb1=(RadioButton)findViewById(R.id.rdb1);
Toast.makeText(ChaActivity.this,
"You have clicked the Radio button: " +
(checkedId == R.id.rdb1? "KBS" : "MBC"),
Toast.LENGTH_SHORT).show();
}
});
ToggleButton toggleButton= (ToggleButton)findViewById(R.id.toggle);
toggleButton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
Toast.makeText(ChaActivity.this,
"Toggle button is" +
(((ToggleButton)v).isChecked()?"On":"Off"),
Toast.LENGTH_SHORT).show();
}
});
}
Button.OnClickListener listener = new Button.OnClickListener() {
public void onClick(View v) {
switch(v.getId()) {
case R.id.btnOpen:
Toast.makeText(ChaActivity.this,
"You have clicked the Open button",
Toast.LENGTH_SHORT).show();
case R.id.btnSave:
Toast.makeText(ChaActivity.this,
"You have clicked the Save button",
Toast.LENGTH_SHORT).show();
}
}};
}
자바이고
xml파일은
<?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:text="@string/hello" />
<Button android:id="@+id/btnSave"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Save"/>
<Button android:id="@+id/btnOpen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Open"/>
<ImageButton android:id="@+id/btnImg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"/>
<EditText android:id="@+id/edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numeric="integer"/>
<CheckBox android:id="@+id/chkAutoSave"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="AutoSave"/>
<CheckBox android:id="@+id/star"
style="?android:attr/starStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<RadioGroup android:id="@+id/rdbGp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioButton android:id="@+id/rdb1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="KBS"/>
<RadioButton android:id="@+id/rdb2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="MBC"/>
</RadioGroup>
<ToggleButton android:id="@+id/toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
이렇게 했습니다..도저히 .setOnCheckedChangeListener (new OnCheckedChangeListener()이부분만 오류나서 뭐가 문제인지 정확히 잘 모르겟네염..
[2012-01-15 21:24:04 - LogCatFilter] Ignoring invalid text regex.
[2012-01-15 21:24:04 - LogCatFilter] Unclosed group near index 4
(new




Logcat에는 뭐라고 나오나요?