jiduvah jiduvah - 5 months ago 58
Android Question

Res/Arrays affecting TextView

I populate a listview from a JSON object. This works fine

setListAdapter(new ArrayAdapter<String>(this, R.layout.list_items, name){
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.list_items, null);
TextView mDistanceTextView = (TextView) v.findViewById(R.id.listitems_distancetxt);
TextView mNameTextView = (TextView) v.findViewById(R.id.listitems_nametxt);
TextView mCategoryTextView = (TextView) v.findViewById(R.id.listitems_categorytxt);
if (mDistanceTextView != null) {
if (mNameTextView != null) {
if(mCategoryTextView != null) {
setImage(type[position], v);

return v;

However in a different activity I want to populate a spinner object so I created a new XML file called arrays.xml and it was located in the res/values folder. When I do this and run the program (without changing any code) the textViews all show null and so don't enter the if statement and so don't populate the view.

Answer Source

In case anybody has stumbled upon this question. It was just a matter of running a clean build

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download