RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.relativeLayout); Button button = (Button) relativeLayout.getChildAt(2); button.setText("Click Me!");
RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.relativeLayout); LinearLayout linearLayout = (LinearLayout) relativeLayout.getChildAt(1); TextView textView = (TextView) linearLayout.getChildAt(0); textView.setTextColor(Color.RED);In this example, we are first retrieving the relative layout object by using the findViewById method. We then retrieve the second child view of the relative layout, which is a linear layout. We cast this linear layout object and retrieve its first child view, which in our case is a text view. Finally, we modify the text color property of the text view to display it in red. These examples suggest that the package library in use is the Android SDK. The java class used is android.widget.RelativeLayout, which is part of the Android widget package.