因为我想在点击图片上制作,当我添加源码:“setOnClickListener(new OnClickListener()”时,它有一些错误?但我不知道发生了什么?
有人可以提出一些建议吗?
public class MainActivity extends Activity {
String[] countries = new String[] {
"South Korea",
"Japan"
};
int[] flags = new int[]{
R.drawable.ic_launcher,
R.drawable.ic_launcher
};
int[] flags1 = new int[]{
R.drawable.ic_launcher,
R.drawable.ic_launcher
};
String[] currency = new String[]{
"South Korean Won",
"Japanese Yen"
};
private ImageView test1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
List<HashMap<String,String>> aList = new ArrayList<HashMap<String,String>>();
for(int i=0;i<10;i++){
HashMap<String, String> hm = new HashMap<String,String>();
hm.put("txt", "Country : " + countries[i]);
hm.put("cur","Currency : " + currency[i]);
hm.put("flag", Integer.toString(flags[i]) );
hm.put("flag1", Integer.toString(flags[i]) );
aList.add(hm);
}
String[] from = { "flag","txt","cur" ,"flag1"};
int[] to = { R.id.flag,R.id.txt,R.id.cur,R.id.flag1};
SimpleAdapter adapter = new SimpleAdapter(getBaseContext(), aList, R.layout.row, from, to);
ListView listView = ( ListView ) findViewById(R.id.listview);
listView.setAdapter(adapter);
**ImageView imageview = (ImageView) findViewById(R.id.flag);
imageview.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
});
}