Note that there are some explanatory texts on larger screens.

plurals
  1. POcustom spinner null pointer exception
    primarykey
    data
    text
    <p>MySpinner.java</p> <p>Below is my custom adapter</p> <pre><code>public class MyAdapter extends ArrayAdapter&lt;String&gt; { public MyAdapter(Context context, int textViewResourceId,String[] objects) { super(context, textViewResourceId, objects); // TODO Auto-generated constructor stub } public View getDropDownView(int position, View convertView,ViewGroup parent) { return getCustomView(position, convertView, parent); } public View getView(int position, View convertView, ViewGroup parent) { return getCustomView(position, convertView, parent); } public View getCustomView(int position, View convertView, ViewGroup parent) { inflater1=(LayoutInflater)this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); rowlayout=inflater1.inflate(R.layout.spinnerlayout, parent, false); txt1=(TextView)rowlayout.findViewById(R.id.textView1); txt1.setText(s[position]); txt1.setTextSize(TypedValue.COMPLEX_UNIT_DIP,DropDownTextSize); txt1.setHeight(RowSize); return rowlayout; } </code></pre> <p>}</p> <p>I made the custom spinner in a different project,which i marked as a library project.</p> <p>Suppose i have a main.xml file with a linear layout. If i add only custom spinner to it,it works fine without any error even if main.xml is in same project or other.</p> <p>But if i add any other widget to linear layout along with the custom spinner,it gives me null pointer exception,only if that main.xml is not in the same project.</p> <p>For main.xml in the same project it works just fine.</p> <p>1) Why is it that my custom spinner is not visible in the pallete in projects with different target api's?</p> <p>2)In other project's main.xml if i add only custom spinner,it works properly but if there is any other component like button,textview etc along with it,it gives me a null pointer exception at</p> <pre><code>txt1.setText(s[position]); </code></pre> <p>Why does this happen?</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.
    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