Cannot find method using android:onclick

Jessie

New Member
I have a ListFragment with an imagebutton in the listview. In the imageButton XML i have android:eek:nclick and i have the properly formatted method in Main.java but still i get the error that it cannot find the method. Any ideas?The XML:\[code\]<ImageButton android:id="@+id/delete_img" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentRight="true" android:eek:nClick="myFunction" android:paddingRight="10dip" android:paddingTop="3dip" android:src="http://stackoverflow.com/questions/15908774/@drawable/delete_icon" />\[/code\]My activity:\[code\]public class Main extends Activity { public static Context appContext; private CommentsDataSource datasource; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { datasource = new CommentsDataSource(this); datasource.open(); // returnNotes(); List<Comment> values = datasource.getAllComments(); // unnecessary? ArrayAdapter<Comment> adapter = new ArrayAdapter<Comment>(this, android.R.layout.simple_list_item_1, values); // setListAdapter(adapter); this must be imported to listFragment // notesfragment super.onCreate(savedInstanceState); setContentView(R.layout.main); appContext = getApplicationContext(); // ActionBar ActionBar actionbar = getActionBar(); actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ActionBar.Tab NotesTab = actionbar.newTab().setText("Notes"); ActionBar.Tab FoldersTab = actionbar.newTab().setText("Folders"); ActionBar.Tab OptionsTab = actionbar.newTab().setText("Options"); Fragment NotesTest = new NotesFragment(); Fragment FoldersFragment = new FoldersFragment(); Fragment OptionsFragment = new OptionsFragment(); NotesTab.setTabListener(new MyTabsListener(NotesTest)); FoldersTab.setTabListener(new MyTabsListener(FoldersFragment)); OptionsTab.setTabListener(new MyTabsListener(OptionsFragment)); actionbar.addTab(NotesTab); actionbar.addTab(FoldersTab); actionbar.addTab(OptionsTab); } public List<Comment> returnNotes() { datasource = new CommentsDataSource(this); datasource.open(); List<Comment> theNotes = datasource.getAllComments(); return theNotes; } // Constructs the options menu with tabs @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.activity_main, menu); return true; } @Override protected void onDestroy() { datasource.close(); super.onDestroy(); } // Tab event listener @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.new_note: Intent intentnote = new Intent(this, NewNote.class); startActivity(intentnote); return true; case R.id.new_folder: Intent intentfolder = new Intent(this, NewFolder.class); startActivity(intentfolder); return true; } return false; } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt("tab", getActionBar().getSelectedNavigationIndex()); }}\[/code\]My tab listener:\[code\]class MyTabsListener implements ActionBar.TabListener { public Fragment fragment; public MyTabsListener(Fragment fragment) { this.fragment = fragment; } @Override public void onTabReselected(Tab tab, FragmentTransaction ft) { // do something on tab reselected? } @Override public void onTabSelected(Tab tab, FragmentTransaction ft) { ft.replace(R.id.fragment_container, fragment); } @Override public void onTabUnselected(Tab tab, FragmentTransaction ft) { ft.remove(fragment); } public void myFunction(View v) { Log.d("uniNote", "hello world"); }}\[/code\]Logcat output:\[quote\] 04-09 17:36:28.080: E/AndroidRuntime(536): FATAL EXCEPTION: main
04-09 17:36:28.080: E/AndroidRuntime(536): java.lang.IllegalStateException: Could not find a method myFunction(View) in the activity class com.finalProject.uniNote.Main for onClick handler on view class android.widget.ImageButton with id 'delete_img'\[/quote\]
 
Top