TextView textView = findViewById(R.id.textView); String message = "Hello World!"; textView.setText(message, textView.getContext());
Toast.makeText(getContext(), "This is a toast message", Toast.LENGTH_SHORT).show();In this example, we are creating a Toast using the getContext method of the TextView to get the context of the view. Package Library: The android.widget package library contains the View and ViewGroup classes which are building blocks for creating Android app's user interface.