搜索框和listview不能同时显现出来在layout中谁放在前面,谁就可以显示,另外个却显示不出来,核心代码如下:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main1);

searchText=(EditText)this.findViewById(R.id.searchText);
listView=(ListView)this.findViewById(R.id.listView);

Intent intent = getIntent();
if (intent.getData() == null) {
intent.setData(ContactsProvider.CONTENT_URI);
} listView.setOnCreateContextMenuListener(this); Cursor mCursor = managedQuery(getIntent().getData(),
ContactColumn.PROJECTION, null, null, null); // 注册的每个列表的表现形式
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_2, mCursor, new String[] {
ContactColumn.NAME, ContactColumn.MOBILENUM },
new int[] { android.R.id.text1, android.R.id.text2 }); listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Uri uri=ContentUris.withAppendedId(getIntent().getData(), id);
String action=getIntent().getAction();
if(Intent.ACTION_EDIT.equals(action)){
startActivity(new Intent(Intent.ACTION_EDIT,uri));
}
else{
startActivity(new Intent(Intent.ACTION_VIEW,uri));
}
}
});
}
xml文件如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
   <EditText
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:id="@+id/searchText"/>
  <ListView
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:id="@+id/listView"/>
</LinearLayout>