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 8848189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:22:06+00:00 2026-06-14T12:22:06+00:00

I have a custom dialog with the format of Header + listview + footer.

  • 0

I have a custom dialog with the format of Header + listview + footer. The corresponding code is as follows: (I don’t mind to share the code but it is over 800 lines) …

    /* Setup dialog layout */
View header = (View)getLayoutInflater().inflate(R.layout.stockcountheader, null);
View footer = (View)getLayoutInflater().inflate(R.layout.stockcountfooter, null);

    final Dialog listDialog;

    listDialog = new Dialog(this, android.R.style.Theme_Dialog);
    listDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    LayoutInflater li = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = li.inflate(R.layout.dialog, null, false);
    listDialog.setContentView(v);
    listDialog.setCancelable(true);

    final AdditemAdapter adapter = new AdditemAdapter(this, R.layout.additemrow, updateitems);
    final ListView filterrow = (ListView) listDialog.findViewById(R.id.dialoglist);
    filterrow.addHeaderView(header);
    filterrow.addFooterView(footer);
    filterrow.setAdapter(adapter);
    i = adapter.getCount();
    listDialog.show();

In the header, I have a radiobutton and intend to control the visibility of the listview row. So, I have the following code: …

    radiostockresGroup = (RadioGroup)listDialog.findViewById(R.id.radiostockres);
    radiostockresButton = (RadioButton) radiostockresGroup.findViewById(radiostockresGroup.getCheckedRadioButtonId());
    radiostockresGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        public void onCheckedChanged(RadioGroup radiostockresGroup, int checkedId) {
            radiostockresButton = (RadioButton) radiostockresGroup.findViewById(checkedId);


            switch(checkedId) {
                case R.id.radioresno:

                    listDialog.findViewById(R.id.tblayout2).setVisibility(View.INVISIBLE);          
                    break;
                case R.id.radioresyes:                      

                    listDialog.findViewById(R.layout.tblayout2).setVisibility(View.VISIBLE);
                    break;
            }

        }
    });

However, it give me the java null pointer error in the “listDialog.findViewById(R.id.tblayout2).setVisibility(View.INVISIBLE); ” line. The xml for the listview and the dialog is as follows:

stocktakerow.xml

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TableLayout android:id="@+id/tblayout2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:shrinkColumns="0"
        android:stretchColumns="*">

        <TableRow 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">    

            <TextView android:id="@+id/txtfieldname"  
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:layout_span="3" 
                android:gravity="top" />

            <EditText android:id="@+id/txtinput"  
                android:layout_toRightOf="@+id/txtfieldname"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_span="3" 
                android:gravity="top" />


        </TableRow>
    </TableLayout>      
</RelativeLayout>

I try to use ” filterrow.findViewById(R.id.tblayout2).setVisibility(View.INVISIBLE);” and still got the same null pointer.

Please kindly give me a hand, thanks a lot in advance!

Kelvin

  • 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-14T12:22:07+00:00Added an answer on June 14, 2026 at 12:22 pm

    If you look at your code, you will notice:

    final ListView filterrow = (ListView) listDialog.findViewById(R.id.dialoglist);
    listDialog.findViewById(R.id.tblayout2).setVisibility(View.INVISIBLE); 
    

    Essentially, you are saying that R.id.tblayout2 is a member of the same thing as R.id.dialoglist. I don’t think they are in this case.

    Not seeing what your class extends, I can only suppose that this should work. If it doesn’t, can you please post the class definitions? Just the line like public class MainActivity extends Activity { will do for both classes.

    findViewById(R.id.tblayout2).setVisibility(View.INVISIBLE); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom dialog which extends Dialog and has a ListView inside its
I have a custom dialog. I use the following code to create it in
I have a custom dialog and despite putting in all the code to inflate
I have a custom Dialog that contains only a TextView to display some text
I have a custom dialog with one editText view and two buttons ok and
I have a custom MFC dialog CMyDialog , with a custom control of type
I have a VideoView inside a custom Dialog. The first time the Dialog is
In my installer I have set WixUIBannerBmp to point to my own custom dialog-banner.bmp
I have defined custom shortcut in General -> Key dialog for Show Whitespace character.
I have visual studio setup project with a custom RadioButtons dialog. How do I

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.