我正在创建一个带有标题的列表视图。我创建了 header.xml,其中有一个图像。但是当我滚动列表标题时也会滚动。它应该总是在顶部。`public class CustomListActivity extends ListActivity {
static final String[] Actress =
//new String[] { "Katrina Kaif", "Aishwarya", "Genelia", "Vidya", "Khalid", "Khalid", "Khalid", "Khalid", "Khalid", "Khalid", "Khalid", "Khalid", "Khalid", "Khalid"};
new String[] { "Aishwarya", "Genelia","Katrina Kaif", "Khalid", "Khalid", "Khalid", "Khalid", "Khalid", "Khalid", "Khalid", "Khalid", "Khalid", "Khalid", "Vidya",};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ListView lv = getListView();
View header = getLayoutInflater().inflate(R.layout.header, null);
lv.addHeaderView(header);
setListAdapter(new MobileArrayAdapter(getApplicationContext(), Actress));
lv.setTextFilterEnabled(true);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
//get selected items
String selectedValue = (String) getListAdapter().getItem(position);
Toast.makeText(this, selectedValue, Toast.LENGTH_SHORT).show();
}
}`