为什么setDropDownViewResource()和setAdapter()不起作用?

时间:2015-12-26 17:20:54

标签: android arrays

Android文档说这应该是填充数组的方法,但它给出的错误我无法弄明白为什么???

package com.example.android.gpacalculator;

    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.widget.ArrayAdapter;
    import android.widget.Spinner;

    public class MainActivity extends AppCompatActivity {

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

        Spinner grade1 = (Spinner) findViewById(R.id.grade1_spinner);
        ArrayAdapter<CharSequence> grade = ArrayAdapter.createFromResource(
                this,
                R.array.grade_array,
                android.R.layout.simple_spinner_item);
        // Specify the layout to use when the list of choices appears
        grade1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
        grade1.setAdapter(grade);

1 个答案:

答案 0 :(得分:0)

将您的微调器代码更改为:

/usr/local/Cellar/mysql/5.6.26/bin