当我单击列表项时,没有任何反应。为什么会这样,我该如何解决?
public class SecondActivity extends Activity {
TextView selection ;
private String[] menus = {"MainActivity","spam"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
ListView listview = (ListView)findViewById(R.id.list) ;
listview.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menus));
}
public void onListItemClick(ListView parent, View v,int position, long id) {
Intent intent = new Intent (SecondActivity.this,ThirdActivity.class);
startActivity(intent);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_second, menu);
return true;
}
}