2013-04-05 71 views
1

一個網站,我在一個機器人,將在我開發了一些代碼website..for一個特定的詞搜索的發展...但它是不完整的......是任何人都能夠幫助..它會成爲我的幫助......非常感謝你閱讀搜索在android系統

public class MainActivity extends Activity { 

    EditText et = new EditText(this); 

    public void onClick(View v){ 
     Editable searchText = et.getText(); 
     Intent intent = new Intent(this, com.example.app.MainActivity.class); 
     intent.putExtra("searchQuery", searchText); 
     startActivity(intent); 
    } 
} 
+0

解釋更多的網站? – 2013-04-05 06:16:11

+0

任何websie例如... http://www.oxfamblogs.org/fp2p/?p = 5672 ...並搜索特定的單詞'樹'...應用程序必須搜索上述網站和顯示搜索結果... – user2223317 2013-04-05 06:29:26

回答

1

試試吧....

<EditText 
    android:id="@+id/edt_search" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@android:color/transparent" 
    android:ellipsize="end" 
    android:hint="Enter Your Text" 
    android:imeOptions="actionGo" 
    android:singleLine="true" 
    android:textSize="14sp" /> 

EditText edt_search; 

edt_search = (EditText) findViewById(R.id.edt_search_book); 
edt_search.setImeOptions(EditorInfo.IME_ACTION_GO); 

edt_search.setOnEditorActionListener(new OnEditorActionListener() { 
        public boolean onEditorAction(TextView v, int actionId, 
            KeyEvent event) { 
          // Log.i("KeyBoard" ,"Inside the Edit Text"); 
          if (actionId == EditorInfo.IME_ACTION_GO) { 

           Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); 
           intent.putExtra(SearchManager.QUERY, edt_search.getText().toString()); // query contains                        
           startActivity(intent); // search string 

          } 
          return false; 
        } 
      }); 
+0

但奇拉格這將僅搜索文本「機器人」 ......我的東西在那裏,我必須改變像intent.putExtra(「查詢」,ev.getText()。的toString());. – user2223317 2013-04-05 06:51:34

+0

請將您的文字改爲「android」 – 2013-04-05 06:54:49

+0

@ user2223317:發生了什麼? – 2013-04-05 07:09:44