Let me get this straight. You want someone to use your app, type in a EditText, and when they click a button, it takes them to a browser and searches for the words they typed in?
XML
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textSize="50dp"
android:id="@+id/textView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Java
public class MainActivity extends AppCompatActivity {
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = (TextView) findViewById(R.id.textView);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//https://www.google.com/#q=
Toast.makeText(MainActivity.this, textView.getText(), Toast.LENGTH_SHORT).show();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com/#q=" + textView.getText())));
}
});
}
}
5
solved GOOGLE SEARCH FROM TEXTVIEW IN ANDROID STUDIO 2.3.3