多线旋转器不工作

时间:2013-03-12 19:38:28

标签: android spinner multiline

我试图让我的多线旋转器工作,以为我无法解决为什么它不会! (它只显示单行 - 所以文本从边缘运行)。我已阅读this,但仍然无效。

这是我的multi_line_spinner.xml文件;

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    style="?android:attr/spinnerDropDownItemStyle"
    android:singleLine="false"
    android:layout_width="match_parent"
    android:layout_height="?android:attr/listPreferredItemHeight" />

我的活动(部分)xml文件;

    <Spinner
        android:id="@+id/schoolSpinner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10" />

这是我编程设置Spinner的地方

更新:我从连接到远程服务器的AsyncTask获取数据。 (成功检索数据)。

ArrayList<String> schoolName = new ArrayList<String>();
    getTTData task = new getTTData();
            task.execute("1");
        try {
            dataSchool = task.get();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ExecutionException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        int x = 0;
        while(x<dataSchool.size()-1)
        {
            schoolName.add(dataSchool.get(x));
            x++;
            schoolID.add(dataSchool.get(x));
            x++;
        }


    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, schoolName);
    adapter.setDropDownViewResource(R.layout.multi_line_spinner);
    schoolSpinner.setAdapter(adapter);
    schoolSpinner.setOnItemSelectedListener(this);

其中schoolName是字符串的ArrayList。 非常感谢任何帮助!

0 个答案:

没有答案