问题:实现继承的抽象方法

  今早在学习过程中,在实现继承的抽象方法时,明明已经实现了,但还是会报错。

  代码如下:

package com.example.listview;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;


public class MainActivity extends Activity {

	private List<Picture> pictureList = new ArrayList<Picture>();
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		initPicture();
		PictureAdapter adapter = new PictureAdapter(MainActivity.this, 
				R.layout.picture_item, pictureList);
		ListView listView = (ListView) findViewById(R.id.list_view);
		listView.setAdapter(adapter);
		listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position,
					long id) {
				// TODO Auto-generated method stub
				Picture picture = pictureList.get(position);
				Log.d("MainActivity","您点击了 : "+picture.getName());
				Toast.makeText(MainActivity.this, "您点击了 : "+picture.getName(), 
						Toast.LENGTH_SHORT).show();
			}
			
		});
	}

	private void initPicture() {
		// TODO Auto-generated method stub
		Picture android = new Picture("Android", R.drawable.android);
		pictureList.add(android);
		
		Picture apple = new Picture("Apple", R.drawable.apple);
		pictureList.add(apple);
		
		Picture safeMgr = new Picture("SafeMgr", R.drawable.guanjia);
		pictureList.add(safeMgr);
		
		Picture linux = new Picture("Linux", R.drawable.linux);
		pictureList.add(linux);
		
		Picture vcr = new Picture("VCR", R.drawable.shexingji);
		pictureList.add(vcr);
		
		Picture set = new Picture("Set", R.drawable.shezhi);
		pictureList.add(set);
		
		Picture windows = new Picture("Windows", R.drawable.windows);
		pictureList.add(windows);
		
		Picture music = new Picture("Music", R.drawable.yinyue);
		pictureList.add(music);
		
		Picture game = new Picture("Game", R.drawable.youxi);
		pictureList.add(game);
		
		Picture camera = new Picture("Camera", R.drawable.zhaoxiangji);
		pictureList.add(camera);
	}
}

  报错:

  抽象方法实现:

  报错提示:

  

  实在找不到错误,然后到QQ群里询问,才知道抽象方法的实现需要自动添加,不能复制或手打。当我删掉自己手打的代码,才用自动添加实现时,就没有报错误了。询问这是为什么,就没有人回答我了。。是这个问题太弱智了吗?

  求解。谢谢

  

 

posted @ 2015-05-05 23:48  Hakka_LGM  阅读(444)  评论(0编辑  收藏  举报