Note that there are some explanatory texts on larger screens.

plurals
  1. POlistview row in custom dialog invisible
    primarykey
    data
    text
    <p>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) ...</p> <pre><code> /* 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(); </code></pre> <p>In the header, I have a radiobutton and intend to control the visibility of the listview row. So, I have the following code: ...</p> <pre><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; } } }); </code></pre> <p>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:</p> <p>stocktakerow.xml</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;TableLayout android:id="@+id/tblayout2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:shrinkColumns="0" android:stretchColumns="*"&gt; &lt;TableRow android:layout_width="fill_parent" android:layout_height="wrap_content"&gt; &lt;TextView android:id="@+id/txtfieldname" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_span="3" android:gravity="top" /&gt; &lt;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" /&gt; &lt;/TableRow&gt; &lt;/TableLayout&gt; &lt;/RelativeLayout&gt; </code></pre> <p>I try to use " filterrow.findViewById(R.id.tblayout2).setVisibility(View.INVISIBLE);" and still got the same null pointer.</p> <p>Please kindly give me a hand, thanks a lot in advance!</p> <p>Kelvin</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload