2 新建SeekActivity 继承Activity
3 在MainActivity中添加tvSeek控件的点击事件
TextView seek = (TextView) findViewById(R.id.tvSeek); seek.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(MainActivity.this,SeekActivity.class); startActivity(intent); } }); 4 在AndroidManifest.xml中注册SeekActivity <activity android:name=".SeekActivity"/> 5 新建布局Seek添加一个EditView 和一个按钮 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:orientation="vertical" android:background="#F2EFEF" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/etContent" android:layout_marginLeft="20dp" android:layout_marginTop="20dp" android:padding="10dp" android:background="#FCFCFC" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="50dp" android:hint="搜索" android:lines="1"/> <Button android:id="@+id/btnSeek" android:layout_marginTop="20dp" android:layout_marginLeft="10dp" android:layout_marginRight="15dp" android:text="搜索" android:layout_width="70dp" android:layout_height="55dp" /> </LinearLayout> </LinearLayout> 6 在 SeekActivity中添加搜索逻辑 public void onCreate(Bundle savedInstanceState) { ... final EditText etContent = (EditText) findViewById(R.id.etContent); Button btnSeek = (Button) findViewById(R.id.btnSeek); btnSeek.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String content = etContent.getText().toString(); mPoiSearch = PoiSearch.newInstance(); mPoiSearch.setOnGetPoiSearchResultListener(new PoiSearchResultListener()); mPoiSearch.searchInCity((new PoiCitySearchOption()) .city(content).keyword("") .pageNum(10)); } }); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { //返回键处理 if (keyCode == KeyEvent.KEYCODE_BACK) finish(); return super.onKeyDown(keyCode, event); } private class PoiSearchResultListener implements OnGetPoiSearchResultListener { @Override public void onGetPoiResult(PoiResult poiResult) { //获取POI检索结果 //待完善 } @Override public void onGetPoiDetailResult(PoiDetailResult poiDetailResult) { } @Override public void onGetPoiIndoorResult(PoiIndoorResult poiIndoorResult) { } }