我试图隐藏一个列表视图,一旦我单击一个项目,然后在其中显示一个按钮,但在 setOnItemClickListener 内部,列表视图是不可访问的。我能做些什么?
// Binding resources Array to ListAdapter
lv.setAdapter(new ArrayAdapter<String>(
MainActivity.this, R.layout.list_venues,
listItems));
// Click event for single list row
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapter,
View view, int position, long arg) {
// TODO Auto-generated method stub
Button here = (Button) findViewById(R.id.iamhere);
lv.setVisibility(View.GONE);
here.setVisibility(View.VISIBLE);
Toast.makeText(
getApplicationContext(),
"Osea que andamos por "
+ listItems.get(position),
Toast.LENGTH_LONG).show();
}
});
非常感谢。