Saturday 15 February 2014

Using a spinner on another view with a different class defined (Android) -


There is a problem loading the array in a spinner located on a different view, right in the arrays.xml array name. Has been defined with. The beerstyle pinner is defined as the ID of a spinner in the carbon calculator_view.xml . When this code is in the main Java class, but there is no extra carbon necclass class, it works.

  Crate on Public Zero); SetContentView (R.layout.carbonationcalculator_view); Find spinner S = (spinner) VVIBID (RID. Beerstyle pinner); ArrayAdapter & LT; CharSequence & gt; Adapter = Arrayadaptor.Creatofrom Resources (this, R. night.bierstyle, R. Layoutbanner Calculator_View); Adapter.setDropDownViewResource (R.layout.carbonationcalculator_view); S.setAdapter (adapter); }  

I'm not sure this will fix the problem, but it seems the adapter What kind of layouts to set up for drop down resources but some confusion setContentView () should be used for the activity that you want to set for activity; However, the drop down resource should be how you want to appear on each row.

What you should do, something like android R.layout.simple_list_item_1 is . You can emulate demos, but instead of their constructor you will use it:

  ArrayAdapter & lt; Charsequence & gt; Adapter = Arrayadaptor.Cretefrom Resource (this, R. night.bearstyle, AndroidR.Lt.simple_l_lite);  

In addition, you do not need to call ArrayAdapter.createFromResource () after using ArrayAdapter.setDropDownViewResource () The third parameter is drop down view resource.


No comments:

Post a Comment