# Android : Call Inner class function. Not working



## speedyguy (Aug 22, 2011)

I need to call an inner class method from outer class. The following code i have written which shows no error but on runtime it throws android error box asking me to force close. I need inner class as i want to extend a class for its method. Is there anyway? Where am i going wrong

Thanks



public class ListtestActivity extends Activity {
    /** Called when the activity is first created. */

    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      new sub1().called();
    }

    public static class sub1 extends ListActivity
    {
    	public void called()
    	{
    		final String[] COUNTRIES = new String[] {"arya","suhail","gogu"};
    	      /*
    	      int i = 0;
    		  File fileList = new File("/sdcard");
    	      if (fileList != null){
    	          File[] filenames = fileList.listFiles();
    	              for (File tmpf : filenames){
    	                 String fname = tmpf.getName();
    	                 COUNTRIES[i++]=fname;
    	              }
    	      }  */

    	      setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES));

    	      ListView lv = getListView();
    	      lv.setTextFilterEnabled(true);

    	      lv.setOnItemClickListener(new OnItemClickListener() {
    	        public void onItemClick(AdapterView<?> parent, View view,
    	            int position, long id) {
    	          // When clicked, show a toast with the TextView text
    	          Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
    	              Toast.LENGTH_SHORT).show();
    	        }
    	      });
    	}
    }

 }


----------

