tags:

views:

30

answers:

1

Hello , im trying to implement a listAdapter that supports integer Arraylists by extending the baseAdapter, when initialize the activity my app crashes. Since im new to android i was wondering if anybody could spot something wrong with my implementation

package com.test.testapp;


import java.util.ArrayList;

import com.test.testapp.R;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class myListAdapterIntegers extends BaseAdapter {


    ArrayList<Integer> arrayIntList = new ArrayList<Integer>();

    Context context;

    myListAdapterIntegers(Context c, ArrayList<Integer> myListAdapterIntegers) {
        this.arrayIntList = myListAdapterIntegers;
        this.context = c;
    }

    @Override
    public int getCount() {
        return arrayIntList.size();
    }

    @Override
    public Object getItem(int location) {
        return arrayIntList.get(location);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        View v = View.inflate(context, R.layout.entry_row_int, null);
        int value = arrayIntList.get(position);

        TextView monthTextView = (TextView) v.findViewById(R.id.text_row_int);

        monthTextView.setText(value);
        return v;
    }


}
+1  A: 

You are calling setText() with an integer value. Android will interpret this as being a string resource ID. If you want it to appear in the list as a number, use setText(String.valueOf(value));

CommonsWare
thx, i noticed that right after i posted :p , pretty stupid of me, thx for the reply and answer though :)
Krewie