Eclipse でイメージボタンの onclicklistener を設定しようとしています。クリックすると、アプリはデフォルトの連絡先アプリにつながるはずです。これは私が持っているコードですが、「}」ブラケットでエラーが発生し、何が問題なのかわかりません。誰でも助けることができますか?
public class First extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
addButtonListener();
}
private void addButtonListener() {
// TODO Auto-generated method stub
//finding your image button
ImageButton btn1 = (ImageButton) findViewById(R.id.imageButton2);
btn1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, 1);
}); //!!!!THE ERROR APPEARS UNDER THE } BRACKET ON THIS LINE!!!
}
@Override
public boolean onCreateOptionsMenu(Menu menu){
//Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.first, menu);
return true;
}
}