我想让我的listview
上的textview
可点击,并打开另一个layout
:
private class IndexListAdapter extends ArrayAdapter<Index>{
public IndexListAdapter(){
super(MainActivity.this, R.layout.listview_item, index);
}
@Override
public View getView(int position, View view, ViewGroup parent){
if (view == null)
view = getLayoutInflater().inflate(R.layout.listview_item, parent, false);
Index currentIndex = index.get(position);
TextView name = (TextView) view.findViewById(R.id.pName);
name.setText(currentIndex.getName());
name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
items.add(new Item(patientTxt.getText().toString(), operatorTxt.getText().toString(),
serialTxt.getText().toString(), deviceTxt.getText().toString(), dateTxt.getText().toString(),
assetTxt.getText().toString(), locationTxt.getText().toString(), qcTxt.getText().toString()));
populateList();
Intent intent = new Intent(MainActivity.this, Item.class);
startActivity(intent);
finish();
}
});
return view;
}
}
我要做的是,在一个listview_item
或列表选项上显示一个名称,当我点击这个名称时,它会打开另一个layout
或页面来显示另一个项目列表。