android.content.res.Resources $ NotFoundException:字符串资源ID#0x2数据库

时间:2016-04-27 12:48:23

标签: java android mysql arrays database

当我尝试测试我的应用时,出现错误。

  

FATAL EXCEPTION:主程序:com.example.android.lab5,PID:12261   android.content.res.Resources $ NotFoundException:字符串资源ID#0x2

这是我的代码

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();
    }
}

我隔离了我的错误,似乎来自那条线:

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

我的java类Jour的代码是:

 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;
    }    
}

谢谢你, 我希望我们能找到答案!

*编辑

这是MeteoJour课程:

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;
    }
}

这是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>

我的日志:

04-27 08:21:24.986 2342-2342 /?我/艺术:迟到-Xcheck:jni 04-27 08:21:25.038 2342-2342 /? D / Insert :: Inserting .. 04-27 08:21:25.210 2342-2342 /? D / Reading ::阅读所有meteojours .. 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:1,最小值:2,最大值:5 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:2,最小值:-1,最大值:3 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:3,最小值:2,最大值:6 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:4,最小值:3,最大值:6 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:5,最小值:4,最大值:5 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:6,最小值:4,最大值:7 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:7,最小值:6,最大值:8 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:8,最小值:4,最大值:5 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:9,最小值:2,最大值:5 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:10,最小值:2,最大值:5 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:11,最小值:2,最大值:5 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:12,最小值:6,最大值:8 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:13,最小值:2,最大值:5 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:14,最低:6,最高:8 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:15,最小值:4,最大值:5 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:16,最小值:2,最大值:5 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:17,最小值:2,最大值:5 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:18,最小值:4,最大值:5 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:19,最低:6,最高:8 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:20,最小值:2,最大值:5 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:21,最小值:-1,最大值:3 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:22,最小值:2,最大值:5 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:23,最小值:2,最大值:5 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:24,最小值:2,最大值:5 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:25,最小值:2,最大值:5 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:26,最低:6,最高:8 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:27,最小值:2,最大值:5 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:28,最小值:2,最大值:5 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:29,最小值:2,最大值:6 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:30,最小值:3,最大值:6 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:31,最小值:2,最大值:5 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:32,最小值:7,最大值:10 04-27 08:21:25.211 2342-2342 /? D / Name :: Id:33,最小值:2,最大值:5 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:34,最低:6,最高:8 04-27 08:21:25.211 2342-2342 /? D /姓名:: Id:35,最小值:2,最大值:5 04-27 08:21:25.218 2342-2360 /? W / GooglePlayServicesUtil:缺少Google Play服务。 04-27 08:21:25.254 2342-2361 /? D / OpenGLRenderer:使用EGL_SWAP_BEHAVIOR_PRESERVED:true 04-27 08:21:25.259 2342-2342 /? D / Atlas:验证地图... 04-27 08:21:25.271 2342-2342 /? W / ResourceType:获取资源号0x00000002时的包标识符04-27 08:21:25.272 2342-2342 /? D / AndroidRuntime:关闭VM 04-27 08:21:25.291 2342-2342 /? E / AndroidRuntime:FATAL EXCEPTION:main进程:com.example.android.lab5,PID:2342 android.content.res.Resources $ NotFoundException:android.content.res.Resources.getText(Resources.java)中的字符串资源ID#0x2 :299)在android.widget.AbsListView.obtainView(AbsListView.java:)的com.example.android.lab5.JourAdapteur.getView(JourAdapteur.java:41)的android.widget.TextView.setText(TextView.java:4132) 2347)在android.widget.List上的android.widget.List上的android.widget.ListView.anMeasure(ListView.java:1182)上的android.widget.List。 android.ReviewLayout.measureChild(RelativeLayout.java:697)在android.view.measure.View.measure(View.java:17547)的android.view.measureGroup.measureChildMithgins上的android.widget.RelativeLayout.onMeasure(RelativeLayout.java:481) (ViewGroup.java:5535)android.widget.FrameLayout.onMeasure(FrameLayout.java:436)android.v上的android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135) iew.View.measure(View.java:17547)在android.view上的android.sview.visionGroup.measureChildWithMargins(ViewGroup.java:5535)android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:391) .View.measure(View.java:17547)在android.view.measure.vision.measure上的android.view.visionGroup.measureChildWithMargins(ViewGroup.java:5535)android.widget.FrameLayout.onMeasure(FrameLayout.java:436) View.java:17547)在Android.widget.Lineout.measureVertical(LinearLayout.java:722)的android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)的android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535) )android.widget.Linout.onMeasure(LinearLayout.java:613)在Android.view.measure.View.measure(View.java:17547)上的android.view.measure.View.measure(View.java:5535) .FrameLayout.onMeasure(FrameLayout.java:436)位于android.view.View的com.android.internal.policy.impl.PhoneWindow $ DecorView.onMeasure(PhoneWindow.java:2615) .measure(View.java:17547)位于android.view.ViewRootImpl.performMevers(ViewRootImpl.java:2015)的android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1173),位于android.view.ViewRootImpl.performTraversals(ViewRootImpl。 java:1379)在android.view.ViewRootImpl上的android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)$ traversalRunnable.run(ViewRootImpl.java:5885)在android.view.Choreographer $ CallbackRecord.run(Choreographer.java) :767)在Android.view.Choreographer,我是android.view.Chocographer.doCrame(Choreographer.java:550),位于android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:753)的android.view.Choreographer.doCallbacks(Choreographer.java:550)在android.os.Handler.handleCallback(Handler.java:739)在Android.app上的android.os.Handler.dispatchMessage(Handler.java:95)android.os.Looper.loop(Looper.java:135)。 Activity.Thread.main(ActivityThread.java:5254)位于java.lang.reflect.Method.invoke(Native Method),位于com.android.internal的java.lang.reflect.Method.invoke(Method.java:372) .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:发送信号。 PID:2342 SIG:9

JourAdapteur类:

公共类JourAdapteur扩展了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);
}

}

2 个答案:

答案 0 :(得分:15)

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

您正在调用期望资源ID的setText(int)。要改为使用setText(CharSequence),您可以将代码更改为例如

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

答案 1 :(得分:0)

您需要使用字符串。这对我有用:

lblMin.setText(Integer.toString(jour.getmTempMin()))