Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7909567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:28:28+00:00 2026-06-03T12:28:28+00:00

I have a custom Layout shown below and I would like to update the

  • 0

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

<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" />

Here is the Java

    LinearLayout L = (LinearLayout)findViewById(R.id.L);
    TextView Identifier = (TextView)L.findViewById(R.id.AMPMIdentifier);
    Identifier.setText("PM");

EDIT: Here is the code from

    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 );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T12:28:30+00:00Added an answer on June 3, 2026 at 12:28 pm

    If I were to guess, right now you’re trying to find, in the OnCLickListener listener, the LinearLayout L from the layout file you posted(which you probably use as the layout for an Activity?!). This will fail because the LinearLayout will not be found and the object will be null. If this what you are doing then try another approach:

    but.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
          LinearLayout parent = (LinearLayout) v.getParent(); // I assumed your MinutePicker extends LinearLayout
          LinearLayout L = (LinearLayout) parent.getParent();
          TextView Identifier = (TextView)L.findViewById(R.id.AMPMIdentifier);
          Identifier.setText("PM");
        }
    });
    

    I haven’t tested the code above(well, I don’t even know how exactly your MinutePicker is built). If this isn’t the problem you may want to add the full exception stacktrace you may get.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have custom component that I can place in my layout file (XML) for
I have custom gallery. Gallery represents items that are frame layout. There are one
I have implemented a custom view within another activity into a XML layout. The
I have a layout with a custom status bar on top [below Apple's status
I have a listView with custom objects defined by the xml-layout below. I want
I have custom classes that I currently instantiate within App.xaml as resources. I want
I would like to create an custom View on Android. I have tried to
I have a quick question about the layout of the page on a custom
I have custom event that has several different subscribers who will all use the
I have a listview that contains values from webservice.Each page contains only 10 listitems

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.