Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android.content.res.Resources$NotFoundException: String resource ID #0x2 Database

When I try to test my app, I get an error.

FATAL EXCEPTION: main Process: com.example.android.lab5, PID: 12261 android.content.res.Resources$NotFoundException: String resource ID #0x2

Here's my code

public class MainActivity extends AppCompatActivity {    
    private Spinner spinnerVille;
    private TextView ville;
    private ListView lstJours;
    int posVille = 0;    

    // Les items
    private ArrayList<Jour> mJours = new ArrayList<Jour>();

    // L'adapteur
    private JourAdapteur mJoursAdapteur;

    private List<MeteoJour> meteojours;

    public static final int REQUEST_TEXT = 0;
    public int laPosition = 0;
    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */
    private GoogleApiClient client;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final DatabaseHandler db = new DatabaseHandler(this);    

        Log.d("Insert: ", "Inserting ..");
        /*db.addMeteoJours(new MeteoJour(1, 2, 5, -2, 10, "SO", 8, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(2, -1, 3, -4, 5, "NO", 8, 30, 0, 2));
        db.addMeteoJours(new MeteoJour(3, 2, 6, 1, 2, "SO", 8, 20, 2, 0));
        db.addMeteoJours(new MeteoJour(4, 3, 6, 3, 10, "SE", 8, 0, 0, 0));
        db.addMeteoJours(new MeteoJour(5, 4, 5, 4, 350, "S", 8, 30, 4, 0));
        db.addMeteoJours(new MeteoJour(6, 4, 7, 5, 0, "O", 8, 0, 0, 0));
        db.addMeteoJours(new MeteoJour(7, 6, 8, 8, 10, "E", 9, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(8, 4, 5, 4, 350, "S", 8, 30, 4, 0));;
        db.addMeteoJours(new MeteoJour(9, 2, 5, -2, 10, "SO", 8, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(10, 2, 5, -2, 10, "SO", 8, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(11, 2, 5, -2, 10, "SO", 8, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(12, 6, 8, 8, 10, "E", 9, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(13, 2, 5, -2, 10, "SO", 8, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(14, 6, 8, 8, 10, "E", 9, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(15, 4, 5, 4, 350, "S", 8, 30, 4, 0));
        db.addMeteoJours(new MeteoJour(16, 2, 5, -2, 10, "SO", 8, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(17, 2, 5, -2, 10, "SO", 8, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(18, 4, 5, 4, 350, "S", 8, 30, 4, 0));
        db.addMeteoJours(new MeteoJour(19, 6, 8, 8, 10, "E", 9, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(20, 2, 5, -2, 10, "SO", 9, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(21, -1, 3, -4, 5, "NO", 9, 30, 0, 2));
        db.addMeteoJours(new MeteoJour(22, 2, 5, 2, 10, "SO", 8, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(23, 2, 5, 2, 10, "SO", 8, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(24, 2, 5, 2, 10, "SO", 8, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(25, 2, 5, 2, 10, "SO", 8, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(26, 6, 8, 8, 10, "E", 9, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(27, 2, 5, 2, 10, "SO", 8, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(28, 2, 5, 2, 10, "SO", 8, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(29, 2, 6, 1, 2, "SO", 9, 20, 2, 0));
        db.addMeteoJours(new MeteoJour(30, 3, 6, 3, 10, "SE", 9, 0, 0, 0));
        db.addMeteoJours(new MeteoJour(31, 2, 5, -2, 10, "SO", 8, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(32, 7, 10, 10, 10, "SO", 8, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(33, 2, 5, 2, 10, "SO", 8, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(34, 6, 8, 8, 10, "E", 9, 15, 1, 0));
        db.addMeteoJours(new MeteoJour(35, 2, 5, 2, 10, "SO", 8, 15, 1, 0));*/
        // Reading all contacts
        Log.d("Reading: ", "Reading all meteojours..");
        //final List<Contact> contacts = db.getAllContacts();
        meteojours = db.getAllMeteoJours();

        for (MeteoJour cn : meteojours) {
            mJours.add(new Jour((String.valueOf(cn.get_id()) + " Mars 2016"), cn.get_minimum(), cn.get_maximum()));
            String log = "Id: " + cn.get_id() + " ,Minimum: " + cn.get_minimum() + " ,Maximum: " + cn.get_maximum();
            // Writing to log
            Log.d("Name: ", log);
        }    

        spinnerVille = (Spinner) findViewById(R.id.spinnerVille);
        ville = (TextView) findViewById(R.id.Ville);
        lstJours = (ListView) findViewById(R.id.lstJours);    

        // Adapteur
        //mHerosAdapteur = new HeroAdapteur(this, MonSingleton.getInstance().getHeros());
        mJoursAdapteur = new JourAdapteur(this, mJours);

        // Assigner l'adapteur à la liste
        lstJours.setAdapter(mJoursAdapteur);    

        // Create an ArrayAdapter using the string array and a default spinner layout
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                R.array.villes, android.R.layout.simple_spinner_item);
        // Specify the layout to use when the list of choices appears
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinnerVille.setAdapter(adapter);

        spinnerVille.setOnItemSelectedListener(new OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> adapter, View v, int position, long id) {

                switch (position) {
                    case 0:
                        ville.setText("Gatineau");
                        posVille = 0;
                        break;
                    case 1:
                        ville.setText("Trois-Rivière");
                        posVille = 1;
                        break;
                    case 2:
                        ville.setText("Montréal");
                        posVille = 2;
                        break;
                    case 3:
                        ville.setText("Sherbrooke");
                        posVille = 3;
                        break;
                    case 4:
                        ville.setText("Alma");
                        posVille = 4;
                        break;
                }    
            }

            public void onNothingSelected(AdapterView<?> parent) {
                // Another interface callback
            }    
        });

        //lstJours.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        lstJours.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                // La seconde activité
                Intent intent = new Intent(MainActivity.this, Meteo.class);
                // Les paramètres

                meteojours = db.getAllMeteoJours();

                laPosition = position;

                MeteoJour cn = meteojours.get(position);
                // Les paramètres
                intent.putExtra("Id", String.valueOf(cn.get_id()));
                intent.putExtra("Min", cn.get_minimum());
                intent.putExtra("Max", cn.get_maximum());
                intent.putExtra("Ressentie", cn.get_ressentie());
                intent.putExtra("VitesseVent", cn.get_vent_vitesse());
                intent.putExtra("VetesseDirec", cn.get_vent_direction());
                intent.putExtra("Ensoleillement", cn.get_ensoleillement());
                intent.putExtra("Prob", cn.get_probabilite());
                intent.putExtra("Pluie", cn.get_pluie());
                intent.putExtra("Neige", cn.get_neige());
                intent.putExtra("villeslct", spinnerVille.getItemAtPosition(posVille).toString());
                intent.putExtra("joursslct", lstJours.getItemAtPosition(position).toString());
                startActivity(intent);
                // Lancer la seconde activité


            }
        });    

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {

        if (requestCode == REQUEST_TEXT) {
            if (resultCode == Meteo.RETURN_CODE_OK) {
                //Toast.makeText(MainActivity.this, data.getStringExtra("prenom"), Toast.LENGTH_SHORT).show();
                mJours.add(new Jour(data.getStringExtra("date"), data.getIntExtra("minimum", 0), data.getIntExtra("maximum", 0)));
                mJoursAdapteur.notifyDataSetChanged();
            }
        }    
    }

    @Override
    public void onStart() {
        super.onStart();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client.connect();
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Main Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse("http://host/path"),
                // TODO: Make sure this auto-generated app deep link URI is correct.
                Uri.parse("android-app://com.example.android.lab5/http/host/path")
        );
        AppIndex.AppIndexApi.start(client, viewAction);
    }

    @Override
    public void onStop() {
        super.onStop();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Main Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse("http://host/path"),
                // TODO: Make sure this auto-generated app deep link URI is correct.
                Uri.parse("android-app://com.example.android.lab5/http/host/path")
        );
        AppIndex.AppIndexApi.end(client, viewAction);
        client.disconnect();
    }
}

I isolated my error and it seems to come from that line:

mJours.add(new Jour((String.valueOf(cn.get_id()) + " Mars 2016"), cn.get_minimum(), cn.get_maximum()));

The code of my java class Jour is :

 public class Jour {    
    private int mTempMin;
    private int mTempMax;
    private String mDates;

    public Jour(String date, int min, int max) {
        mTempMin = min;
        mTempMax = max;
        mDates = date;
    }    

    public String getmDates() {
        return mDates;
    }

    public void setmDates(String mDates) {
        this.mDates = mDates;
    }

    public int getmTempMin() {
        return mTempMin;
    }

    public void setmTempMin(int mTempMin) {
        this.mTempMin = mTempMin;
    }

    public int getmTempMax() {
        return mTempMax;
    }

    public void setmTempMax(int mTempMax) {
        this.mTempMax = mTempMax;
    }    
}

Thank you, I hope we can find an answer!

*EDIT

Here's the MeteoJour class:

public class MeteoJour {

    //private variables
    int _id;
    int _minimum;
    int _maximum;
    int _ressentie;
    int _vent_vitesse;
    String _vent_direction;
    int _ensoleillement;
    int _probabilite;
    int _pluie;
    int _neige;


    // Empty constructor
    public MeteoJour(){

    }
    // constructor
    public MeteoJour(int id, int minimum, int maximum, int ressentie, int vent_vitesse, String vent_direction, int ensoleillement, int probabilite, int pluie, int neige){
        this._id = id;
        this._minimum = minimum;
        this._maximum = maximum;
        this._ressentie = ressentie;
        this._vent_vitesse = vent_vitesse;
        this._vent_direction = vent_direction;
        this._ensoleillement = ensoleillement;
        this._probabilite = probabilite;
        this._pluie = pluie;
        this._neige = neige;
    }

    // constructor
    public MeteoJour(int minimum, int maximum, int ressentie, int vent_vitesse, String vent_direction, int ensoleillement, int probabilite, int pluie, int neige){
        this._minimum = minimum;
        this._maximum = maximum;
        this._ressentie = ressentie;
        this._vent_vitesse = vent_vitesse;
        this._vent_direction = vent_direction;
        this._ensoleillement = ensoleillement;
        this._probabilite = probabilite;
        this._pluie = pluie;
        this._neige = neige;
    }


    public int get_id() {
        return _id;
    }

    public void set_id(int _id) {
        this._id = _id;
    }

    public int get_minimum() {
        return _minimum;
    }

    public void set_minimum(int _minimum) {
        this._minimum = _minimum;
    }

    public int get_maximum() {
        return _maximum;
    }

    public void set_maximum(int _maximum) {
        this._maximum = _maximum;
    }

    public int get_ressentie() {
        return _ressentie;
    }

    public void set_ressentie(int _ressentie) {
        this._ressentie = _ressentie;
    }

    public int get_vent_vitesse() {
        return _vent_vitesse;
    }

    public void set_vent_vitesse(int _vent_vitesse) {
        this._vent_vitesse = _vent_vitesse;
    }

    public String get_vent_direction() {
        return _vent_direction;
    }

    public void set_vent_direction(String _vent_direction) {
        this._vent_direction = _vent_direction;
    }

    public int get_ensoleillement() {
        return _ensoleillement;
    }

    public void set_ensoleillement(int _ensoleillement) {
        this._ensoleillement = _ensoleillement;
    }

    public int get_probabilite() {
        return _probabilite;
    }

    public void set_probabilite(int _probabilite) {
        this._probabilite = _probabilite;
    }

    public int get_pluie() {
        return _pluie;
    }

    public void set_pluie(int _pluie) {
        this._pluie = _pluie;
    }

    public int get_neige() {
        return _neige;
    }

    public void set_neige(int _neige) {
        this._neige = _neige;
    }
}

Here is the R.array.ville XML:

<string name="app_name">Lab5</string>

<string-array name="joursSemaine">
    <item>Dimanche le 28 février 2016</item>
    <item>Lundi le 29 février 2016</item>
    <item>Mardi le 1 mars 2016</item>
    <item>Mercredi le 2 mars 2016</item>
    <item>Jeudi le 3 mars 2016</item>
    <item>Vendredi le 4 mars 2016</item>
    <item>Samedi le 5 mars 2016</item>
</string-array>

<string-array name="villes">
    <item>Gatineau</item>
    <item>Trois-Rivière</item>
    <item>Montreal</item>
    <item>Sherbrooke</item>
    <item>Alma</item>
</string-array>

My log :

04-27 08:21:24.986 2342-2342/? I/art: Late-enabling -Xcheck:jni 04-27 08:21:25.038 2342-2342/? D/Insert:: Inserting .. 04-27 08:21:25.210 2342-2342/? D/Reading:: Reading all meteojours.. 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 1 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 2 ,Minimum: -1 ,Maximum: 3 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 3 ,Minimum: 2 ,Maximum: 6 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 4 ,Minimum: 3 ,Maximum: 6 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 5 ,Minimum: 4 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 6 ,Minimum: 4 ,Maximum: 7 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 7 ,Minimum: 6 ,Maximum: 8 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 8 ,Minimum: 4 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 9 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 10 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 11 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 12 ,Minimum: 6 ,Maximum: 8 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 13 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 14 ,Minimum: 6 ,Maximum: 8 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 15 ,Minimum: 4 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 16 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 17 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 18 ,Minimum: 4 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 19 ,Minimum: 6 ,Maximum: 8 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 20 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 21 ,Minimum: -1 ,Maximum: 3 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 22 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 23 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 24 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 25 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 26 ,Minimum: 6 ,Maximum: 8 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 27 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 28 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 29 ,Minimum: 2 ,Maximum: 6 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 30 ,Minimum: 3 ,Maximum: 6 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 31 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 32 ,Minimum: 7 ,Maximum: 10 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 33 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 34 ,Minimum: 6 ,Maximum: 8 04-27 08:21:25.211 2342-2342/? D/Name:: Id: 35 ,Minimum: 2 ,Maximum: 5 04-27 08:21:25.218 2342-2360/? W/GooglePlayServicesUtil: Google Play services is missing. 04-27 08:21:25.254 2342-2361/? D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true 04-27 08:21:25.259 2342-2342/? D/Atlas: Validating map... 04-27 08:21:25.271 2342-2342/? W/ResourceType: No package identifier when getting value for resource number 0x00000002 04-27 08:21:25.272 2342-2342/? D/AndroidRuntime: Shutting down VM 04-27 08:21:25.291 2342-2342/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.android.lab5, PID: 2342 android.content.res.Resources$NotFoundException: String resource ID #0x2 at android.content.res.Resources.getText(Resources.java:299) at android.widget.TextView.setText(TextView.java:4132) at com.example.android.lab5.JourAdapteur.getView(JourAdapteur.java:41) at android.widget.AbsListView.obtainView(AbsListView.java:2347) at android.widget.ListView.measureHeightOfChildren(ListView.java:1270) at android.widget.ListView.onMeasure(ListView.java:1182) at android.view.View.measure(View.java:17547) at android.widget.RelativeLayout.measureChild(RelativeLayout.java:697) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:481) at android.view.View.measure(View.java:17547) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535) at android.widget.FrameLayout.onMeasure(FrameLayout.java:436) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135) at android.view.View.measure(View.java:17547) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535) at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:391) at android.view.View.measure(View.java:17547) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535) at android.widget.FrameLayout.onMeasure(FrameLayout.java:436) at android.view.View.measure(View.java:17547) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436) at android.widget.LinearLayout.measureVertical(LinearLayout.java:722) at android.widget.LinearLayout.onMeasure(LinearLayout.java:613) at android.view.View.measure(View.java:17547) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535) at android.widget.FrameLayout.onMeasure(FrameLayout.java:436) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2615) at android.view.View.measure(View.java:17547) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2015) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1173) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1379) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) at android.view.Choreographer.doCallbacks(Choreographer.java:580) at android.view.Choreographer.doFrame(Choreographer.java:550) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 04-27 08:21:28.734 2342-2342/com.example.android.lab5 I/Process: Sending signal. PID: 2342 SIG: 9

JourAdapteur class:

public class JourAdapteur extends ArrayAdapter {

private Context mContext;
private LayoutInflater mInflater;

public JourAdapteur(Context context, ArrayList<Jour> jours) {
    super(context, 0, jours);
    mContext = context;
    mInflater = LayoutInflater.from(context);
}

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

    if (theView == null) {
        theView = mInflater.inflate(R.layout.jour_list_item, parent, false);
    }

    // Le hero
    Jour jour = this.getItem(position);

    // Aller chercher les objets
    TextView lblMin = (TextView) theView.findViewById(R.id.lblMin);
    TextView lblMax = (TextView) theView.findViewById(R.id.lblMax);
    TextView lblDate = (TextView) theView.findViewById(R.id.lblDate);

    // Assigner les valeurs
    lblMin.setText(jour.getmTempMin());
    lblMax.setText(jour.getmTempMax());
    lblDate.setText(jour.getmDates());


    // Retourner la vue
    return theView;
}

@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    return getView(position, convertView, parent);
}

}

like image 280
Programmer Avatar asked Apr 27 '16 12:04

Programmer


1 Answers

lblMin.setText(jour.getmTempMin());
lblMax.setText(jour.getmTempMax());

You're calling setText(int) that expects a resource id. To use setText(CharSequence) instead, you can change the code to e.g.

lblMin.setText(String.valueOf(jour.getmTempMin()));
lblMax.setText(String.valueOf(jour.getmTempMax()));
like image 115
laalto Avatar answered Sep 20 '22 21:09

laalto