首页上一页 1 下一页尾页 1 条记录 1/1页
为什么我设置Spinner的点击事件会报错啊?
发表在Android图书答疑
2015-02-13
是否精华
是
否
版块置顶:
是
否
package com.example.fw17;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Spinner;
public class MainActivity extends Activity {
private Spinner spinner1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spinner1=(Spinner) findViewById(R.id.spinner1);
spinner1.getSelectedItem();
spinner1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String text=parent.getItemAtPosition(position).toString();
Log.i("haha", text);
}
});
}
}
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Spinner;
public class MainActivity extends Activity {
private Spinner spinner1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spinner1=(Spinner) findViewById(R.id.spinner1);
spinner1.getSelectedItem();
spinner1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String text=parent.getItemAtPosition(position).toString();
Log.i("haha", text);
}
});
}
}