gpt4 book ai didi

java - 在android中搜索一个网站

转载 作者:行者123 更新时间:2023-11-30 03:40:26 26 4
gpt4 key购买 nike

我正在开发一个可以在网站上搜索特定单词的机器人。为此我开发了一些代码……但它还不完整……有人能帮忙吗……它会对我有帮助...非常感谢您阅读

 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);
}
}

最佳答案

试一试....

<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;
}
});

关于java - 在android中搜索一个网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15827049/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com