找不到java AdapterView[微调器]
我目前正在使用我的第一个旋转器。但是我有点在onItemSelectedListener期间被卡住了,因为我无法实现它。我第一次尝试遵循《公共物品》一书中的方法,但它会起作用——但我的方法现在也不起作用
起初,我试图让我的活动直接实现AdapterView——但唯一的结果是eclipse告诉我AdapterView接口不可用,并要求我创建它。。。但是我现在又犯了同样的错误
public class Lunchplace extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mensa);
Context c = getApplicationContext();
Spinner dateSelection = (Spinner)findViewById(R.id.date);
//ArrayAdapter<String> aa = new ArrayAdapter<String>(this, 安卓.R.)
// get all the little tidbits of extra informations
Bundle extras = getIntent().getExtras();
String location = extras.getString("Mensa");
// this function will download the Lunchfile - if necessary
Data lunchData = new XMLData(c);
// set the header text
TextView mensaname = (TextView)findViewById(R.id.header);
mensaname.setText(location);
// get the spin view out of the xml
Spinner spin = (Spinner)findViewById(R.id.date);
// attach it to an adapter
ArrayAdapter adapter = ArrayAdapter.createFromResource(
this, R.array.days, 安卓.R.layout.simple_spinner_item);
// I should be able to put a custom layout of the spinner in there.. I bet
adapter.setDropDownViewResource(安卓.R.layout.simple_spinner_dropdown_item);
spin.setAdapter(adapter);
spin.setOnClickListener(
new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent,
View view, int position, long id) {
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}
);
// set the current day of the week as the default selection
spin.setSelection(Tools.getDayOfWeek());
// get the tablelayout
TableLayout tl = (TableLayout)findViewById(R.id.MenuTable);
lunchData.getMenuforDay(c,tl,location);
TextView counterTV = new TextView(c, null, R.style.MenuField);
}
}
有人知道我如何解决那个问题吗
# 1 楼答案
实现OnItemSelectedListener没有什么特别之处。试着这样做: