文章詳情頁
android - 繼承一個BaseAdapter類后重寫了一些方法,但是這些方法在父類中找不到,這是為什么?
瀏覽:145日期:2024-09-10 16:44:49
問題描述
繼承BaseAdapter類
class MyAdapter extends BaseAdapter{@Overridepublic int getCount() { return 0;}@Overridepublic Object getItem(int position) { return null;}@Overridepublic long getItemId(int position) { return 0;}@Overridepublic View getView(int position, View convertView, ViewGroup parent) { return null;} }
這是父類中的方法
問題解答
回答1:因為這些方法是BaseAdapter從它的父類或者實現接口中繼承來的,需要開啟Show inherited才能在Structure中顯示出來。
回答2:導包導錯了。
回答3:BaseAdapter是個抽象類,實現了ListAdapter接口,getCount、getItem這幾個方法都在ListAdapter接口里,但是BaseAdapter沒寫具體實現,所以你要繼承BaseAdapter必須寫這幾個方法的實現。
回答4:子類中的方法 父類中當然找不著了,都不是一個類 。父類中的方法在子類中能找到。
排行榜
