Custom Layout Interact with another layouts TextView

invi08

New Member
I have a custom Layout shown below and I would like to update the TextViews text from within that layout file. But the TextView is not within the layout file at all.Sorry I don't know how to properly describe what I am implementing. If anyone could even advise on the correct terminology that would be much appreciated.Basically I want to change the TextView from AM to PM when the button that is inflated from com.grogorian.android.control.MinutePicker is clicked. I am using the below java within com.grogorian.android.control.MinutePicker,but keep getting a null pointer\[code\]<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/L" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_vertical|center_horizontal"> <com.grogorian.android.control.MinutePicker android:id="@+id/Picker2" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"> </com.grogorian.android.control.MinutePicker> <TextView android:id="@+id/AMPMIdentifier" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="AM" />\[/code\]Here is the Java\[code\] LinearLayout L = (LinearLayout)findViewById(R.id.L); TextView Identifier = (TextView)L.findViewById(R.id.AMPMIdentifier); Identifier.setText("PM");\[/code\]EDIT: Here is the code from\[code\] but = new Button( context ); but.setTextSize( TEXT_SIZE ); but.setText( "-" ); // Decrement once for a click but.setOnClickListener(new View.OnClickListener() { public void onClick(View v) {LinearLayout L = (LinearLayout)findViewById(R.id.L); TextView Identifier = (TextView)L.findViewById(R.id.AMPMIdentifier); Identifier.setText("PM"); } }); this.setLayoutParams( new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT ) ); LayoutParams elementParams = new LinearLayout.LayoutParams( ELEMENT_WIDTH, ELEMENT_HEIGHT ); addView( but, elementParams );\[/code\]
 
Back
Top