public boolean onQueryTextSubmit(String s) { if (sv != null) { // 獲得輸入管理對象
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { // 這將讓鍵盤在全部的狀況下都被隱藏,可是通常咱們在點擊搜索按鈕後,輸入法都會乖乖的自動隱藏的。
imm.hideSoftInputFromWindow(sv.getWindowToken(), 0); // 輸入法若是是顯示狀態,那麼就隱藏輸入法
} sv.clearFocus(); // 不獲取焦點
} //將輸入數據傳入classinfo中
Intent intent=new Intent(ClassSearch.this,ClassInfo.class); intent.putExtra("infoData",s); startActivity(intent); return true; try { ClientKey.put("classID", s); Authorization.put("Class",ClientKey); String content = String.valueOf(Authorization); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); conn.setConnectTimeout(5000); //設置容許輸出
conn.setDoOutput(true); conn.setRequestMethod("POST"); //設置contentType
conn.setRequestProperty("Content-Type","application/json"); OutputStream os = conn.getOutputStream(); os.write(content.getBytes()); os.close(); } catch (JSONException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }